Results 1 to 6 of 6

Thread: Passing Variables to forms

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    2

    Exclamation

    It has been 3 years since I did any VB code and I've forgotten how to pass a variable to a form as it loads. Can anyone help, I know its simple but...

    Sean

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    In what respect.If you are loading your form for the first tiem, your variables will be empty till you load them. If you are loading a second form and what a variable from form1 for use in form2 load then put it in the form2 activate event.
    ex. set both forms with same width

    on form 1 you have a public variable intWidth
    Public intWidth
    intWidth = Form1.width

    In form2 activate.
    Form2.width = intWidth
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    You can store them in a public variable, or you can write to them directly.

    Code:
    Form2.Command1.Caption = "Hello"

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    2

    Lightbulb

    To explain it a bit better:
    I have a main form which is using a table in access. The Index on this table is RecID. I need to open a second form and link the two forms by passing RecID variable from form 1 to variable GetRecID in form 2. Thanx for the help!

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    assuming you know how to get the value of RecID
    Form1
    Public MyVar
    MyVar = RecID

    Form2 Activate Event
    GetRecId = MyVar
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    Addicted Member Dim A's Avatar
    Join Date
    Jul 2000
    Posts
    201

    Isn't there a better way?

    I normally use public setItem subroutines to protect private data...

    But isn't there a way to just parametize the load event or something like that? To set initial states at instantiation time?

    Thanks.

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