making textbox locked via
RH

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Making a TextBox Locked via VBA

Making a TextBox Locked via VBA

resolvedResolved · High Priority · Version 2016

Manny has attended:
Access Intermediate course
Access Advanced course

Making a TextBox Locked via VBA

Hello Team,

i have a designed form that is set as my home page of my access database. From this Homepage, a user can do multiple tasks.
I wish to make a specific text box "locked" on another form via vba (then i wish to make another button that will unlock the form).

I have only got as far as this

Forms![PriceByFundDETAILF]![Price].Locked = True

Is anyone able to advise?

Edited on Mon 6 Aug 2018, 13:48

RE: Making a TextBox Locked via VBA

Hi Manny,

Thank you for the forum question.

The VBA line:

Forms![PriceByFundDETAILF]![Price].Locked = True

Lock editing of the Price field on the PriceByFundDETAILF form.

Forms![PriceByFundDETAILF]![Price].Locked = False

will unlock the same field.


To luck and unlock from another form the form with the text boxes needs to be open.

The line below will open the PriceByFundDETAILF form:

DoCmd.OpenForm "PriceByFundDETAILF"


The line below will close and save the form after you have locked/unlock the Price field:

DoCmd.Close acForm, "PriceByFundDETAILF", acSaveYes


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Making a TextBox Locked via VBA

Hi Jens,

Thanks so much. After much googling, I have got close. This is what I have now, however, it does not seem to save the changes after this has closed the form?

DoCmd.OpenForm "PriceByFundDETAILF"
[Forms]![PriceByFundDETAILF]![Price].Enabled = False
DoCmd.Close acForm, "PriceByFundDETAILF", acSaveYes

I also tried the the "save" as a seperate line and i was unsuccessful

DoCmd.OpenForm "PriceByFundDETAILF"
[Forms]![PriceByFundDETAILF]![Price].Enabled = False
DoCmd.Save acForm, "PriceByFundDETAILF"
DoCmd.Close acForm, "PriceByFundDETAILF", acSaveYes

Any idea why this might be the case?
Any help would be appreciated.

RE: Making a TextBox Locked via VBA

Hi Manny,

You do not lock/unlock, you are enable/unenable.

DoCmd.OpenForm "PriceByFundDETAILF"
[Forms]![PriceByFundDETAILF]![Price].lock = False
DoCmd.Close acForm, "PriceByFundDETAILF", acSaveYes



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Making a TextBox Locked via VBA

Hi Jens,

Thanks, I can see this Locking when I am in breakmode. However, it does not save this properly once the form closes? I am still able to edit the textbox after this code has run?

Manny

RE: Making a TextBox Locked via VBA

Hi Manny,

I cannot spot any issues in your code.

I tested the code below in one of my data bases with success.




Sub doUnlock()
DoCmd.OpenForm "customers", acDesign

Forms![customers]![credit limit].Locked = False
DoCmd.Close acForm, "customers", acSaveYes


End Sub



Sub doLock()
DoCmd.OpenForm "customers", acDesign

Forms![customers]![credit limit].Locked = True
DoCmd.Close acForm, "customers", acSaveYes


End Sub

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Making a TextBox Locked via VBA

Ah Jens, can you believe it worked!! i added ,ac design like in your code.

Thanks for your help!!

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Splittng a database

Split your database into two (at least).

Keep all of your code, forms, reports, etc. in one 'code' database and all of your tables in another 'data' database which is then linked to the 'code' database.

This makes modifications, updates and back-ups that much easier and allows you to work on a new version of your 'code' database without affecting existing users. It also makes it easier should you wish to convert a single user databases into a multi-user networked version.

View all Access hints and tips


Server loaded in 0.06 secs.