A form I have designed has a subform embedded within it that changes depending on what button a user presses. There are three options that the user can press, and upon pressing one, it changes the SourceObject to another form within the same database, re-sizes it to that form and finally makes it visible to the user.
There will be a lot of this going on throughout the use of this database and rather than having to copy and paste the same code over and over again into each button_click event, I'd like to build a function/sub with parameters that can change which form it's referencing for the SourceObject and height.
For example, here's the code I'm currently using for a button press:
Code:
Private Sub Button1_Click()
Me.childFrame.Height = Form_Name.Detail.Height
Me.childFrame.SourceObject = "FormName"
Me.childFrame.Visible = True
End Sub
I'd like to create a function like the one below that I can call each time that will change the childFrame, Form_Name and "FormName" properties of the three lines called above. Something like:
Code:
Public Function RefreshSubform(childFrame As ???, Form_Name As ???, FormName As String)
Me.childFrame.Height = Form_Name.Detail.Height
Me.childFrame.SourceObject = FormName
Me.childFrame.Visible = True
End Function
That way I can then just call the one line feeding in my chosen variable names:
Code:
Private Sub Button1_Click()
RefreshSubform childA, formA, formNameA
End Sub
However, I have no idea what data types these variables need to be, never mind if this is actually possible.
Any help would be highly appreciated