Link to home
Start Free TrialLog in
Avatar of justinhaynes
justinhaynes

asked on

calling variables from subs.

I have this in a module:
-----------
Public Sub Open_Next_Form(thisformname, nextformname)

MsgBox thisformname
MsgBox nextformname

GlobalCustomerID = thisformname.ID
thisformname.Form.refresh
DoCmd.OpenForm nextformname

End Sub
--------------


I call it this way:
-----------------
    Private Sub btnConsumerDebt_Click()

MsgBox Form.Name

nextformname = frmDebtsConsumer
Call Open_Next_Form(Me.Form, nextformname)


'GlobalCustomerID = ID
'Form.refresh
'DoCmd.OpenForm "frmDebtsConsumer"


End Sub
------------------

When I click this button I get a Type Mismatch at "msgbox thisformname"

When I comment out the msgboxes, I get:

"runtime error 2494: The action or method requires a form name argument"
at
DoCmd.OpenForm nextformname


Thanks.

ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of justinhaynes
justinhaynes

ASKER

thanks, this worked!  I am new to VBA and really appreciate this help.  I am to build a database for a client.  When I originally estimated how much time it would take me, I didn't realise that some of the functionality would necessitate coding.  I'll probably be posting more here.  

thanks again, mbizup.
I'm glad I could help out.  I noticed from your member profile that you've been around for a while, but this is your first question.  I've found this site extremely helpful in helping me through the learning curves on many of my projects.   Many minds are better than one anyday!

Good luck :-)