Solved

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

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

Independent Software Vendors: 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

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…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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.

713 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