Solved

calling variables from subs.

Posted on 2006-11-26
3
610 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
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…

735 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