Solved

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

Posted on 2013-11-02
2
606 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

626 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