-
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
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks