?
Solved

calling variables from subs.

Posted on 2006-11-26
3
Medium Priority
?
621 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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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