I have a need to potentially preform the same actions on multiple fields of a form based on if it is clicked or not. I have written the code below in an attempt to minimize the amount of code and make it easier to follow. The problem is that when I try to compile it I get a Compile error: Method or data member not found. Is it possible to pass a field name through a "call function" that can be used as a data member? When I run the code in a single Sub in line with the rest of the code it works fine. Just didn't want to have to duplicate the code everywhere else it's needed in case I need to update or modify it sometime later.
VBA Code:
Private Sub Inv_Num_Click()
myUnlock INV_Num
End Sub
.
.
.
Private Sub myUnlock(myField)
Dim myResult As Boolean
If Me.myField.Locked = True Then
myResult = (MsgBox("Do you want to unlock the " & myField & " field?", vbYesNo, "Unlock field") = vbYes)
If myResult = True Then
<more code>
End Sub