Solved

help me!!   why it cannot change?

Posted on 2001-08-19
7
171 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
7 Comments
 
LVL 1

Expert Comment

by:harsh008_k
Comment Utility
*****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
Comment Utility
use the sql properly in second recordset
0
 

Expert Comment

by:avibudkov
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:arnab79
Comment Utility
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
Comment Utility
Try this

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

0
 
LVL 1

Expert Comment

by:sanjeevjain1973
Comment Utility
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
Comment Utility
thanks Hornet241 :)

i have tried yours and it worked!

thanks again to all of you!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now