EDITED
I have nearly 20 forms. I want to use a Public Sub written in a module to prevent writing some lines of code on each form's Got Focus event.
So, To lock an active form (on its Got focus or any similar event) , I wrote this code in a module:
Option Compare Database
Public strFormName as string
_____________________________
Public Sub LockThisForm()
Forms(strFormName).AllowEdits = False
End Sub
Then, on Got Focus event of the form, I wrote the following code:
strFormName = Me.Name
LockThisForm ' (a Sub name defined in a module as written above)
It worked for Main Form perfectly, but not working for Subform, and shows runtime error number 2450 (Access cannot find the referenced form "Orders Subform")
Subform name is referenced differently in a variable but I don't know how? And where to change it, in the module or on Got Focus event of the Form.
Some practical guidelines will be appreciated