Solved

How do I pass an argument to an Excel userform in VBA ?

Posted on 2013-11-02
2
599 Views
Last Modified: 2013-11-02
Hi Experts,

I am building an application in Excel VBA and have a user form (ufOrdersForm) with a text box control which holds an invoice number.

When the user double-clicks the text box I want its value (an invoice number) to pass to another form (ufSalesForm) as follows......

Private Sub teInvoiceNo1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

   Application.ScreenUpdating = False
   Unload Me
   ufSalesForm.Show
   Application.ScreenUpdating = True

End Sub

How do I pass the argument from the procedure above to the intended user form ?

Thanks in anticipation ?
Toco
0
Comment
Question by:Tocogroup
[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 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39619108
Toco,
Here are two ways to pass the value:
1. Declare a variable as Public in a regular module. Put a value in that variable before unloading the first userform. The second userform (ufSalesForm) can then interrogate that variable.
2. Hide the first userform instead of unloading it. The second userform can then get the value from the first userform. When the second userform closes and returns control to the calling sub  teInvoiceNo1_DblClick, you can then unload the first userform.

Brad
0
 

Author Closing Comment

by:Tocogroup
ID: 39619128
Thanks Brad. Tried both methods and they work great.
Cheers
Toco
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel automatically jump to row based on date 5 40
Lookup range formula 7 27
Excel - merge column values 3 26
Unique List in UserForm 3 23
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

734 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