Reputation: 1221
I'm trying to call a form Private Sub from another form, and when I run it I'm getting Run-time error 424: Object Required
. The erroring code is the Call frm_Main.add_arg(filt_key, filt)
at the end of:
Private Sub btn_go_to_pat_Click()
Dim filt_key As String
Dim filt As String
filt_key = "cont_hist_filter"
filt = "MRN = " & Me.MRN
DoCmd.OpenForm "frm_Main"
Call frm_Main.add_arg(filt_key, filt)
End Sub
The target sub is:
Public Sub add_arg(arg_key As String, arg_value As String)
MsgBox "Received arg_key " & arg_key & " with value " & arg_value
my_args.Add arg_key, arg_value
End Sub
Upvotes: 0
Views: 245
Reputation: 27634
The name of the form class is Form_<form name>
, as you see it in the Project Explorer in the VBE.
So you need
Call Form_frm_Main.add_arg(filt_key, filt)
or
Dim fMain As Form_frm_Main
Set fMain = Forms!frm_Main
Call fMain.add_arg(filt_key, filt)
Upvotes: 1