Solved

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

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

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Excel Macro - Lookup-Highlight 4 25
Excel 6 19
cannot get subtotal to work 8 18
How to compare data in excel 5 28
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now