PDA

View Full Version : [SOLVED] Parameters



Daxton A.
05-12-2005, 11:28 AM
Hey everyone! What I'm trying to figure out here is how would I pass one variable from a form to another form? I tried to find it in a search but, well obviously, I did not find how to do it. I probably just didn't type in the correct words or something.

I do need to add that I am a "NOOB", when it comes to this, lol.
B/c if is too much of a hassle, I will just copy the values to the spreadsheet & then just pull them off of there to the other form. But, I hope that it isn't too much of a hassle.
:think:

Thanks Everyone,
Daxton

mvidas
05-12-2005, 12:16 PM
Daxton,

What you're thinking can be done without having to put the value onto a spreadsheet, but without more information of what you're trying to do it would just be a guessing game for us.

Does one form have a textbox on it for input, and you want to refer to that in the other form? If so, you could do something like:


x = UserForm1.TextBox1.Value

If not, can you explain a little more?
Matt

BlueCactus
05-12-2005, 12:21 PM
The easiest way is to declare the variable as public in your calling module.

I've also written a KB article that achieves something very similar and could probably be easily adapted for your purpose. http://www.vbaexpress.com/kb/getarticle.php?kb_id=470

In your case you'll just need to put the calling code inside the first userform, instead of the calling (non-form) module.

Have fun!

Daxton A.
05-12-2005, 12:39 PM
I'm sorry that I provided such a little bit of information. What I need this for is I have the spreadsheet called "Daily Shipping Log" & I'm in the process of creating 2 forms, a Customer Form and a Part Form. Part form is a "child" form, I can call it that for what I need it. I know that it's not possibly a child form, I just know the basic definition. But what these forms are for is I have a list of each in hidden cells so I don't loose the data. But what it does is have a customer combo box showing all the customer's names. Per each customer, they have certain parts. Now I want to be able to do is to tell which customer is selected before I pull up the parts form. To do this, like I know how lol, is by passing parameters.

Thanks again,
Daxton

mvidas
05-12-2005, 12:45 PM
You should still be able to use something like


Dim CustName As String
CustName = CustomerForm.CustomerNameComboBox.Value

to get this done, as the customer form should retain it's values, unless you Unload it each time you call the Part form (which I doubt you would)
Matt

Daxton A.
05-12-2005, 01:02 PM
Thanks ahead of time everyone, I probably won't respond for another day is why I'm going ahead and thanking you because I am about to leave work.

Daxton