Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-11-02
2
Medium Priority
?
614 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
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

877 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