98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Access VBA Training and help » Making a TextBox Locked via VBA
Making a TextBox Locked via VBA
Resolved · 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?
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
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
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Access tip:Splittng a databaseSplit your database into two (at least). |