Routine in my form:
Code:
Private Sub cmdSomeClick()
Dim theform As String
theform = Me.Name 'grabs the name of the active form
SomeModule.SomeRoutine (theform)
End Sub
Code in SomeModule
Code:
Sub SomeRoutine (theform)
Forms(theform).label.Caption = "A name" 'just an example
End Sub
I have code like above throughout my database. The top two lines in the cmdSomeClick() routine never changes but the third one's module name or routine name may change but the variable "theform" will always be referenced as Me.Name. I know I can declare theform variable globally by putting it before the routine or functions such as
Code:
Public theform As String
Is there a way I can do something similar with the line?:
so that in my code when I call the routine I only need to enter the third line and avoid repeating the top two lines everythime I want to call this routine or function from whatever form I am using? i.e. Do something like below:
New Routine in my form:
Code:
Private Sub cmdSomeClick()
SomeModule.SomeRoutine (theform)
End Sub
New Code in SomeModule
Code:
Public theform As String
Public theform = Me.Name
Sub SomeRoutine (theform)
Forms(theform).label.Caption = "A name" 'just an example
End Sub
Access 2007