Results 1 to 5 of 5

Thread: How do I pass values between forms?

  1. #1
    redhat_25
    Guest

    How do I pass values between forms?

    For example:

    I have a form A, which displays Customer data including Company name. User enters Company and on Lost Focus event I display form B, which shows the Datagrid with all customers for this company.

    So, how do I pass the value of txtCompany.text from form A to form B as a parameter that I can include in SELECT statement.

    I appreciate any suggestions.

  2. #2
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Why are you doing it on Lost Focus?
    Don't Rate my posts.

  3. #3
    redhat_25
    Guest
    Well, I thought, after user types company name, the next thing to tab. What are the other options: command buttom? And it is not critical right now. I don't know how to tie two forms together by value. Please advice me on that.
    Thanks.

  4. #4
    Hyperactive Member Ed Lampman's Avatar
    Join Date
    Mar 2001
    Posts
    273
    The easiest way to pass the value is to set up a Public variable in form B for this.

    In Form B declarations:
    Public strCompany as String

    Private sub Form_Load()

    (your SQL statment would be here to load the grid using strCompany)

    end sub

    Then, however you decide to send the value, just set it like this in form A:
    Code:
    With FormB
         .strCompany = FormA.txtCompany.Text
         .Show
    end with

  5. #5
    redhat_25
    Guest
    Thank you, Ed.

Posting Permissions

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



Click Here to Expand Forum to Full Width