Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Returning the values of form to code (2000/2003)

    Subject edited by HansV to correct typo

    Hi everyone,

    I am using some VBA to create letters in a set way, part of the code opens a user form with three dropdowns inside, upon clicking ok I want to return to the original code that called the form and carry the values of the combos selected by the user to the main code???

    I can call the form, the bit I'm missing is how to return to the main code

    I have tried FrmOnwardProvider.Hide but this causes the whole code to end!

    Thanks
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Returning the values of form to code (2000/2003)

    You can define global variables in a standard module (the kind of module that you create by selecting Insert | Module in the Visual Basic Editor), e.g.

    Public gstrLastName As String

    In the code behind the OK button on the userform, set the value of the global variables:

    gstrLastName = Me.txtLastName

    You can then use the global variables when the form has been closed.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Returning the values of form to code (2000/2003)

    Many thanks Hans,

    I had tried that with no luck, however I then realised how stupid I had been. I never put a break point in so the code was running to the finish before I had checked if it had worked!!

    Thanks again
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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