Results 1 to 4 of 4

Thread: accessing values from 1 form to another

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2002
    Posts
    1

    accessing values from 1 form to another

    If I have a checkbox on one form, and I want to access it's value on another form, what do I do? Any held would be great. Thanks.

  2. #2
    Addicted Member mepaco's Avatar
    Join Date
    Mar 2002
    Location
    Jackson, MS
    Posts
    185
    From Form2

    VB Code:
    1. Form1.Checkbox1.Value

  3. #3
    Myrrdan
    Guest
    mepaco's code is right.
    I usually have a couple forms at least on most of my apps.
    Am always sending data back and forth between them.
    Only thing you have to watch out for is making sure any changes are reflected in linked forms.

    I usually end up with

    if frmMain.checkbox1.value = 1 then
    msgbox "You have checked on the main form.",vbokonly
    else
    msgbox "You do not have checked on the main form.",vbokonly

    end if

    this would check to see if the main form was checked, could place it in any form.

    Also can call functions from any form like this.
    'GetDir function grabs the apps path.

    strPath = fmMain.GetDir
    then u save coding by only needing the fuction in one form.

  4. #4
    Addicted Member mepaco's Avatar
    Join Date
    Mar 2002
    Location
    Jackson, MS
    Posts
    185
    I'm guessing since this is a checkbox you won't have to work with it much but if you did then you could always set a reference to it and make it easier to work with, and more efficient I believe.

    VB Code:
    1. Dim checkbox1 As CheckBox
    2. Set checkbox1 = Form1.checkbox1
    3. If checkbox1.Value Then     'This is the checkbox on Form1
    4.     checkbox1.Enabled = False
    5. End If

    If you set a reference to it like this then you can work with it just like it was a local control.

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