Results 1 to 10 of 10

Thread: Problems with a variable

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Hermosillo, Sonora, Mexico.
    Posts
    38

    Problems with a variable

    I have a form(form1) and I have to call another form(form2) to do some proces. In the form2 i have to look for a information from the client that have in form1.
    form2.text1.text = form1.text1.text
    and some times the information than the form1 give me is like that past client example:

    form1.text 1 = 1
    call form2
    form2.text1.text = form1.text1.text
    form2.text1.text shoul be 1

    I out from form2 and change text1 from form1
    form1.text1.text = 5
    call for2
    form2.text1.text = form1.text1.text
    the result should be 5 but in some ocasions is the last number in this case 1.

    Why?.

    Thanks for advance
    Sorry for my english.

  2. #2
    Addicted Member
    Join Date
    Sep 1999
    Posts
    229
    Hi arazcon,

    Don't know how you call Form2 from Form1.
    But could you try to use Load, Unload and Show:

    Load Form2
    Form2.Show

    Hope it helps
    Keiko

  3. #3
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485
    Can show your source code?

    Did you put this under Command button's Click event?

    Code:
    Form2.Text1.Text = Form1.Text1.Text
    Wanna try this in Form1.Text1_Change event?
    Code:
    Form2.Text1.Text = Form1.Text1.Text
    or
    Form2.Text1.Text = Text1.Text 'Since it's local

  4. #4
    Addicted Member
    Join Date
    Sep 1999
    Posts
    229
    the different between Form1.Show and Load Form1 is that
    Form1.Show will only show the form. It may not update the
    value. But if you Load a form, it will update the values of all objects.

    If you mentioned a command button, then

    Load Form2
    Form2.Text1.Text = Form1.Text1.Text
    Form2.Show

    Hope it helps
    Keiko

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Hermosillo, Sonora, Mexico.
    Posts
    38

    Thanks everybody

    Hi everybody. This is a very simple sample that show you what i want and wath is my problem. some times the form2 show the past information from form1.

    thanks for advance again.

  6. #6
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485
    Try to put the code in Form2 in this way
    Code:
    Private Sub Form_Activate()
      Text1.Text = Form1.Text1.Text
      Text2.Text = Form1.Text2.Text
    End Sub

  7. #7

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Hermosillo, Sonora, Mexico.
    Posts
    38

    Thanks again

    Thanks HardDisk. My questions are :
    1. What is the diference between Form_Load and Form_Activate
    2. What is better

    Thanks

  8. #8

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Hermosillo, Sonora, Mexico.
    Posts
    38

    Thanks again

    Thanks HardDisk. My questions are :
    1. What is the diference between Form_Load and Form_Activate
    2. What is better

    Thanks

  9. #9
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485

    Re: Thanks again

    Originally posted by arazcon
    Thanks HardDisk. My questions are :
    1. What is the diference between Form_Load and Form_Activate
    2. What is better

    Thanks
    You are welcome!

    I'll reply based on my own experienced.
    1) Form_Load will be triggered when you do a Load Form/Form.Show or access to it's objects, such as textboxes and stuff. To trigger Form_Load again, you need to terminate the form, which will trigger the Form_Terminate event. Form_Activate will be triggered when the form GotFocus/goes on top. This can be seen when you made some changes to your form1 textboxes, and then click on Form2, the update will be made without clicking on the command button.
    2) Both has its usage. For commands needed to be run once, put them into Form_Load. Form_Activate is useful when you want to Refresh your recordset queries, after making some changes to the DB, and to get the updated records when clicking on the particular Form.

    Hope these help.

  10. #10

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Hermosillo, Sonora, Mexico.
    Posts
    38

    Thanks very much

    Thanks very much again and happy new year.

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