Solved

help me!!   why it cannot change?

Posted on 2001-08-19
7
185 Views
Last Modified: 2012-05-04
hi there,

i have 2 forms here. i enter StudentID in Text1 in form1. i want the
StudentID and it data based on the StudentID to be  display in Text1 in form2.

so, i did this in form1:

Form2.Text1.Text = Text1.Text

below is my coding and i will tell my problem below the coding:
coding in form2:

-------------------
Private Sub Form_Activate()

Dim Log As String
Text1.Text = Form1.Text1.Text

Log = "StudentID='" & Text1.Text & "'"
Data1.Recordset.FindFirst StudentID

If Not Data1.Recordset.NoMatch Then
 
  Text1.Text = Data1.Recordset![StudentID]
  Text2.Text = Data1.Recordset![Name]
  Text3.Text = Data1.Recordset![SubjectCode]
  Text4.Text = Data1.Recordset![Subject]
  Text5.Text = Data1.Recordset![Gred]
  Text6.Text = Data1.Recordset![Marks]
         
  Text7.Text = Data2.Recordset![SubjectCode]
  Text8.Text = Data2.Recordset![Subject]
  Text9.Text = Data2.Recordset![Gred]
  Text10.Text = Data2.Recordset![Marks]
           
 
 
         
  End If
 
End Sub
---------

Private Sub Form_Load()

strSQL = "select * from QueryStudent where SubjectCode ='SHA 2233'"
          Data1.RecordSource = strSQL
           
MySQL = "select * from QueryStudent where SubjectCode='SHB 2523'"
          Data2.RecordSource = MySQL            
           
           
End Sub
=======================

my problem here is when i enter S10 as first entering StudentID in form1, the form2 will display all the S10 data
in Text1 - Text10 in form2.

but, what happened is, when i enter S12 as second entering StudentID in form1, the form2 only show S12 data
in Text1 - Text6. The Text7 - Text10 still show the S10 data.

why it is happened?
please help me...
it's really make me headache.

thanks in advance!


0
Comment
Question by:arnab79
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:harsh008_k
ID: 6403390
*****u r using a diff recordset****.which is not refreshed.
use refresh method of datacontrol,ewhcih will give u solution
0
 
LVL 1

Expert Comment

by:harsh008_k
ID: 6403392
use the sql properly in second recordset
0
 

Expert Comment

by:avibudkov
ID: 6403437
You can work with synchronized recordsets using the "clone" method which create
a copy of the recordset .
Example:
.
.
.
ObjConn.BeginTrans
set objRs = CreateObject("Adodb.recordset")
objRs.CursorType = 3
objRs.LockType = 4
set objRS.activeConnection = objConn
objRS.open strSql
Set objClone  = objRs.Clone
.
.
.
By using this method you don't need to make the assignment.

regards
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:arnab79
ID: 6403828
thanks to both of you :)

but, i'm sorry..
i still cannot understand and don't know how to do it.

harsh008 k, would you please tell me how to work with sql with data2.Recordset. and where to put it in my coding?

avibudkov, i'll study your suggestion now because it's quite hard for me to understand that since i'm newcomer in this vb world.

thanks.
0
 
LVL 3

Accepted Solution

by:
Hornet241 earned 20 total points
ID: 6404078
Try this

Log = "StudentID='" & Text1.Text & "'"
Data1.Recordset.FindFirst StudentID
Data2.Recordset.FindFirst StudentID

0
 
LVL 1

Expert Comment

by:sanjeevjain1973
ID: 6404905
First you are entring StudentID on From1.Text1 then tis displayning Form2 data.


For entring Second studentID , u again come back on form1.
I think its not refreshing Data control. I think Form2 still im memory. So when u come back from form2 to Form1 then write Form2_Unload event

Sub Form2_Unload ()
  Set Form2 = Nothing
End sub

Then it will release from memory. Now enter Student ID on form1.Text1 then load form2.

It should work.


Sanjeev
0
 

Author Comment

by:arnab79
ID: 6405670
thanks Hornet241 :)

i have tried yours and it worked!

thanks again to all of you!
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question