Cannot pass a form object to a module
- From: rlntemp-gng@xxxxxxxxx
- Date: Mon, 16 Jul 2007 08:07:44 -0700
I have one module where I would like to launch 2 different forms (that
do exist), based on a form object and string that is passed into it.
(prmTable is a string, not a table object simply because prmTable is
only used in the form's caption)
(I know I could put this code behind a form object, but my goal is to
modularize this code somewhat and get this technique down so that I
can import this code to other applications in the future where I need
to use one code module to pass in different forms)
I have the following code in a VBA module object called mod_UTIL:
<begin code>
Private Sub ViewOutputData(prmForm As Form, prmTable As String)
DoCmd.OpenForm prmForm, acFormDS 'open the form in Datasheet view
prmForm.Caption = "Data Output from " & prmTable
End Sub
<end code>
Here, is where the above module is called:
<begin code>
Private Sub cmdW1Data_Click()
ViewOutputData Forms!frmW1DataOut, "tblW1DataOut"
End Sub
<end code>
....in another module:
Private Sub cmdW2Data_Click()
ViewOutputData Forms!frmW2DataOut, "tblW2Dataout"
End Sub
To try and pass in the form object, I have tried various flavors for
this trying to get this to work:
ViewOutputData Forms!frmW1DataOut, "tblW1Dataout" yields:
"Access cannot find the form frmW2DataOut"
ViewOutputData "Forms!frmW1DataOut", "tblW1Dataout" yields:
"type mismatch error"
ViewOutputData [Forms!frmW1DataOut], "tblW1Dataout" yields:
"access can't find the field "|" referred in your expression."
ViewOutputData frmW1DataOut, "tblW1Dataout" yields:
"By Ref Argumant type mismatch'
What is still not correct with my code? Any assistance is very much
appreciated.
Thank you.
.
- Follow-Ups:
- Re: Cannot pass a form object to a module
- From: Bobort
- Re: Cannot pass a form object to a module
- From: Tom van Stiphout
- Re: Cannot pass a form object to a module
- Prev by Date: Re: How to Keep Only the First Value in a Comma Delineated String
- Next by Date: Re: Problem updating memo field with string data from form
- Previous by thread: How to Keep Only the First Value in a Comma Delineated String
- Next by thread: Re: Cannot pass a form object to a module
- Index(es):
Relevant Pages
|