I want to set the On Click Event of a button to unlock the current control a user is on. I know the code to set the property of a named control, but I don't want a button for every control I want to unlock. Is there a 'Me' option for controls?
Yes, there is a Me.ActiveControl. But, if you click on the command button it becomes the active control. So, there may be a better way to do this, but my first inclincation is to create a public variable to store the current control name and put the code in the GotFocus event of each control that you are concerned with to set the variable to the current control's name. Then, when you press the button you will have the name of the last control that had the focus in that variable.
You can then use that in code
Code:
Me.Control(MyVariableHere).Locked = False
But, why have the controls locked anyway if they will just automatically unlock when entered? That really doesn't make sense. I would (and have in a database I created) lock all the controls on the form and have an "Edit" button which will unlock the controls for editing. I then have the controls lock again when the On Current event fires.
put something as a Tag in the controls you want to set and then:
Code:
Dim ctl As Control
For each ctl in Controls
If ctl.Tag = "MyTagHere" Then
ctl.Locked = False
End If
Next
and then just use the opposite for the locked (True).