I am trying to build a MACRO to lock a field in a subform when a condition is met, but I am not having any luck. I keep getting "Action Failed" window and I have tried changing things everyway I can think of.
I am trying to build a MACRO to lock a field in a subform when a condition is met, but I am not having any luck. I keep getting "Action Failed" window and I have tried changing things everyway I can think of.
I assume you have the following requirement:
To Lock a control on a subform based on the value of a control on the main form.
I am attaching a mdb file:
What have I done:
In my main form i have a check box when you check it the textbox control on subform aa is locked:
code used:
Private Sub Form_Current()
Select Case Me.Yes
Case Is = True
[Table2].Form![aa].Locked = True
Case Is = False
[Table2].Form![aa].Locked = False
End Select
End Sub
Private Sub Yes_AfterUpdate()
Select Case Me.Yes
Case Is = True
[Table2].Form![aa].Locked = True
Case Is = False
[Table2].Form![aa].Locked = False
End Select
End Sub
the code is used in the AfterUpdate event of the CheckBox and also on the OnCurrent Event of the Form.
because this ensures that Lock is opened when you want to create a new entry or use the navigation button to navigate to a entry in which the checkbox is unchecked. It also ensures that the field is locked or unlocked depending on the of the Check box when the form opens
refer to attached mdb file.
if this solves your problem mark this thread solved
Hi Diane,
I would highly-recommend taking the route that Maximus posted over using built in Macros. Try to get away from using macros, they are very limiting and in my opinion much harder to manage then properly written VBA code.
Dan
Access Development