Solved

calling variables from subs.

Posted on 2006-11-26
3
598 Views
Last Modified: 2010-05-18
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.

0
Comment
Question by:justinhaynes
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 18016126
Try revising the sub to define the paramters as Form and string::

Public Sub Open_Next_Form(thisformname as Form, nextformname as String)

MsgBox thisformname.Name
MsgBox nextformname

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

End Sub


Then call it like this:

nextformname = "frmDebtsConsumer"    '*** nextformname should be Dimmed as string.
Call Open_Next_Form(Me, nextformname)
0
 

Author Comment

by:justinhaynes
ID: 18016531
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.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18016548
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 :-)
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question