I would like to create a function in a module that can be used to open a form from another form. So, in my module, I have:
Public Function fcn_opn_frm(str_frm As String)
Dim frm As Form
Set frm = Forms(str_frm)
DoCmd.OpenForm frm, acNormal
End Function
Then I have a command button in a form which is supposed to open another form. This has code thus:
Private Sub cmd_opn_frm_work_Click()
Call fcn_opn_frm(frm_data_work)
End Sub
But it doesn't work. I get a 'Variable Not Defined' error which highlights the 'frm_data_work' in the command button code.
Where am I going wrong? Also, I understand I don't have to do it this way, but am always looking for alternative ways to do things in Access as this invariably expands my knowledge of how to do stuff in general..
Thanks for any assistance..!