C
Chuck
I have a form and report which are almost identical in terms of content
(i.e., many of the controls have the same name and show the same data).
Currently, the same code exists in both the form and the report. This code
essentially sets the properties of some of the controls when the form or
report opens.
Example
Sub in Form:
Sub MyForm_Open()
Me!Control1.caption="Hi"
Me!Control2.caption="There"
End Sub
Sub in Report:
Sub MyReport_Open()
Me!Control1.caption="Hi"
Me!Control2.caption="There"
End Sub
Since the names of the controls are the same in both the form and report, I
would like to move the appropriate lines to a procedure in another module:
Sub in Form:
Sub MyForm_Open()
Call Set_Properties(Me)
End Sub
Sub in Report:
Sub MyReport_Open()
Call Set_Properties(Me)
End Sub
Sub in Module:
Sub Set_Properties(MyName as Form)
MyName!Control1.caption="Hi"
MyName!Control2.caption="There"
End sub
Now, the problem I am obviously having is that the code in the module only
applies to the form (since MyName is declared as Form). How can I have it
work for both the form and the report?
Thanks
(i.e., many of the controls have the same name and show the same data).
Currently, the same code exists in both the form and the report. This code
essentially sets the properties of some of the controls when the form or
report opens.
Example
Sub in Form:
Sub MyForm_Open()
Me!Control1.caption="Hi"
Me!Control2.caption="There"
End Sub
Sub in Report:
Sub MyReport_Open()
Me!Control1.caption="Hi"
Me!Control2.caption="There"
End Sub
Since the names of the controls are the same in both the form and report, I
would like to move the appropriate lines to a procedure in another module:
Sub in Form:
Sub MyForm_Open()
Call Set_Properties(Me)
End Sub
Sub in Report:
Sub MyReport_Open()
Call Set_Properties(Me)
End Sub
Sub in Module:
Sub Set_Properties(MyName as Form)
MyName!Control1.caption="Hi"
MyName!Control2.caption="There"
End sub
Now, the problem I am obviously having is that the code in the module only
applies to the form (since MyName is declared as Form). How can I have it
work for both the form and the report?
Thanks