Solved

calling variables from subs.

Posted on 2006-11-26
3
578 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now