why is this happen?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: why is this happen?

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    why is this happen?

    [Originally posted by maria]

    hello there :)

    my problem is i want to pass value (which is user Name) from text1.text in Form1 to text1.text in Form2.

    well, i can do this only for the first user.

    When a first user, for an example Adam put his name in text1 in form1,his name will appear in text1 in form2. i'm success in this. But, my problem is, when the second user (Eva) put her name in text1 form1, her name did not appear in text1 form2 because Adam's name still appear in the text1 form2.

    Why this is happen? why the text1 form2 did not show Eva's name?
    Could anybody tell me why?
    i'm using MSAccess 97 as my database

    Thanks in advance!

    below is my coding.

    ===================
    Private Sub Form_Activate()
    Dim Log as string

    Log = "Name='" & Text1.Text & "'"
    Data1.Recordset.FindFirst Log
    If Not Data1.Recordset.NoMatch Then
    Text1.Text = Data1.Recordset![Name]
    Text2.Text = Data1.Recordset![Department]

    End If

    End Sub
    ======================
    Private Sub Form_Load()


    Text1.Text = Form1.Text1.Text

    End Sub



    ----

    ooppss...the way i called form2 from form1 is:

    me.hide
    load Form2
    Form2.Show

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:why is this happen?

    [Originally posted by Greg DeBacker]

    You show a Form_Activate event and a Form_Load event in your code sample. I'm assuming the Form_Activate is Form1 and the Form_Load is from Form2.

    If you are populating the Form2.Text1.Text in the Form_Load event of Form2 it will only populate the TextBox when the Form loads.

    You show this code:

    me.hide
    load Form2
    Form2.Show

    That loads Form2. This populates the Text1.Text with "Adam" the first time. If you don't ever Unload Form2 then you can't load it again to populate the Text1 TextBox on Form2.

    Instead of having it in the Form_Load event you could do this.

    Someplace in Form1 you would have this code.

    Form2.Text1.Text = Text1.Text
    Form2.Show

    You don't need to load Form2 because when you access any control of Form2 the Form_Load event will automatically fire first. I'm not sure why you are hiding Form1 but you could show Form2 as Modal to keep people from accessing Form1 while Form 2 is visible. Like this:

    Form2.Text1.Text = Text1.Text
    Form2.Show vbModal

    Greg



  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:why is this happen?

    [Originally posted by maria]

    thanks greg! :)

    i'll try your solution.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center