?
Solved

help me!!   why it cannot change?

Posted on 2001-08-19
7
Medium Priority
?
188 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 60 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

752 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