[RESOLVED] locking text boxes on user form
I have a user form that fires up when the user clicks on a command button with 'Show_Form' macro assigned to it.
the code for this is in module1 -
Sub Show_Form()
Main_Form.Show
End sub
Now, part of the procedure on the 'Main_Form' is to enter various bits of data and once validated the text boxes are locked and greyed out and the code for this is behind the user form called 'Main_Form'.
This file is then saved for another user to open and authorise.
My problem is that when the 2nd user opens the file to authorise, the text boxes are no longer locked or greyed out!!!
I have tried using .Locked = True method in code in Module1 quoted above but none of the variables are recognised.
It's late, my head hurts and I want to go home so any help to stop my brain hurting more tomorrow morning would be great.....
Thanks all
Re: locking text boxes on user form
Use the form's Open event (or Show - whatever) to check if there are values in the text boxes and then lock them if they are. Maybe add some validation code as well. Or add a boolean field like fldLocked, set it when it's first locked, then check that.
You could also do the reverse - have locked as the default (set in design view and save), and only unlock when needed.
Basically, the textboxes default property in design view is unlocked, and that's how the form is saved, so when it's opened again, it defaults to that. Setting it to locked while the app is running doesn't save that change to the form design.
Re: locking text boxes on user form
I think a good sleep has helped (as well as your advice ;) )
Need to put check in user_Form_initialize code. Doh!
Resolved :)