Solved

help me!!   why it cannot change?

Posted on 2001-08-19
7
179 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

828 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