• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

help me!! why it cannot change?

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
arnab79
Asked:
arnab79
1 Solution
 
harsh008_kCommented:
*****u r using a diff recordset****.which is not refreshed.
use refresh method of datacontrol,ewhcih will give u solution
0
 
harsh008_kCommented:
use the sql properly in second recordset
0
 
avibudkovCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
arnab79Author Commented:
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
 
Hornet241Commented:
Try this

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

0
 
sanjeevjain1973Commented:
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
 
arnab79Author Commented:
thanks Hornet241 :)

i have tried yours and it worked!

thanks again to all of you!
0

Featured Post

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now