Results 1 to 4 of 4

Thread: VBA Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    484

    VBA Question

    Dear all,

    I am working on an Access file, and inside there, I have a lot of forms, but I need to somehow pass a variable from one form to the other, can anyone show me how to do that?

    thank you very much

    PlayKid

  2. #2
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    Re: VBA Question

    any variables that I want to be available to ALL forms, I usually put in a module

    VB Code:
    1. Public strData As String

    Now, I can do the following in frmMain
    VB Code:
    1. Private Sub cmdInput_Click()
    2.     strData = "w00t"
    3.     frmTwo.Show
    4. End Sub

    and for frmTwo's Form_Load:
    VB Code:
    1. Private Sub Form_Load()
    2.    Me.Caption = strData
    3. End Sub
    Now, frmTwo's Caption would be equal to a variable that you set in frmMain.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    484

    Re: VBA Question

    Can I say something like this?

    VB Code:
    1. TextBox12 = [Form 1].[TextBox11]

  4. #4
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: VBA Question

    Quote Originally Posted by PlayKid
    Can I say something like this?

    VB Code:
    1. TextBox12 = [Form 1].[TextBox11]

    If TextBox12 is a global variable like LostAngel posted, then yes.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


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