I have several controls that do the same thing in different forms. I currently have individual private subs in each form associated with each control. Each private sub has the same code that I copied/pasted from form to form (the names of the controls have remained constant from form to form).
I want to turn this into a public function module to help streamline and tidy up my database.
The problem is that the VBA in these private subs refer to values in controls within each form. Here is an example:
The 'Me' grammar doesn't seem to work in a public function. What do I change so that it applies this code to the controls in which ever form is currently open?
I have a feeling that I have to use a string statement, declare a variable as the current form and then use that variable in replace of 'Me'. But I don't understand how to code variables very well and I can't seem to find a straight answer on declaring the current form name as a variable when I search Access forums.
Any help would be appreciated. Thanks!
I want to turn this into a public function module to help streamline and tidy up my database.
The problem is that the VBA in these private subs refer to values in controls within each form. Here is an example:
Code:
Private Sub AgeStartCombo_AfterUpdate()
If Me.AgeStartCombo = "All Ages" Then
Me.AgeEndCombo = "All Ages"
Me.AgeStartCodeTxt = "1"
Me.AgeEndCodeTxt = "16"
End If
End Sub
The 'Me' grammar doesn't seem to work in a public function. What do I change so that it applies this code to the controls in which ever form is currently open?
I have a feeling that I have to use a string statement, declare a variable as the current form and then use that variable in replace of 'Me'. But I don't understand how to code variables very well and I can't seem to find a straight answer on declaring the current form name as a variable when I search Access forums.
Any help would be appreciated. Thanks!