Cannot pass a form object to a module



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.

.



Relevant Pages

  • Re: Cannot pass a form object to a module
    ... based on a form object and string that is passed into it. ... Private Sub ViewOutputData ... ViewOutputData Forms!frmW1DataOut, "tblW1DataOut" ...
    (comp.databases.ms-access)
  • Re: IsSubform....?
    ... >> How can i know if form is SubForm passing ... > global variable of type Form to pass a reference to the form object ... > between the calling routine and the called routine. ... > Private Sub Form_Open ...
    (microsoft.public.access.modulesdaovba)
  • RE: Search through Forms
    ... but they will all use the same form object. ... Private Sub SearchBox_AfterUpdate ... "KKash" wrote: ... There are Thousands of Forms/Records so using a Combo Box or List Box is not ...
    (microsoft.public.access.forms)
  • Re: Multithreaded WinForms question
    ... I've been bitten by this before and, yes, the bugs that arise ... Private Sub MyObject_SomeEvent ... I guess my confusion stemmed from not realizing the Form object has an ... Invoke method as well. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: tracking changes...this is getting a little too confusing for me
    ... "Me" is the form object, "Me.txtIssueNo" uniquely identifies the record and "BeforeUpdate" is the calling event. ... Public Function libHistory(frmForm As Form, lngID As Long, strTrans As String) ... Dim db As DAO.Database, rs As Recordset, strSQL As String, strUser As String ... If ctl.Name Like "cmd*" Then GoTo Skip ...
    (comp.databases.ms-access)