Consulting

Results 1 to 6 of 6

Thread: Parameters

  1. #1
    VBAX Contributor Daxton A.'s Avatar
    Joined
    Jun 2004
    Location
    Biloxi, Mississippi
    Posts
    143
    Location

    Red face Parameters

    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.


    Thanks Everyone,
    Daxton

  2. #2
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    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

  3. #3
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    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!

  4. #4
    VBAX Contributor Daxton A.'s Avatar
    Joined
    Jun 2004
    Location
    Biloxi, Mississippi
    Posts
    143
    Location

    ...

    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

  5. #5
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    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

  6. #6
    VBAX Contributor Daxton A.'s Avatar
    Joined
    Jun 2004
    Location
    Biloxi, Mississippi
    Posts
    143
    Location

    ...

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •