arnab79
asked on
why it not show data?
i have 2 forms here. i want the DBGrid in form2 show data based onthe StudentNumber from Text1 in form1. i have success doing this. THANKS to all who have helped me before!
but, my problem is the DBGrid only show the first time entering StudentNumber only.
for example:
i enter StudentNumber for the first time : AH970001
the DBGrid show all the AH970001 data.
but when i enter StudentNumber for the second time: AH 970031
the DBGrid still show the AH970001 data.
ooppss..
i put this coding in my Form1
Form2.Show vbModal
Form2.Text1.Text=Text1.Tex t
is there any wrong here?
could anybody teach me on how to settle this problem?
i appreciate any help!
thanks in advance.
Private Sub Form_Load()
Dim MySQL As String
Dim Log As String
Dim db As Database
Text1.Text = Form1.Text1.Text
Set db = DBEngine(0).OpenDatabase(" c:\WINDOWS \Desktop\P sm2\PSM2.m db")
MySQL = "SELECT * FROM QStudentSubject where StudentNumber='" & Text1.Text & "'"
Data1.RecordSource = MySQL
Data1.Refresh
Log = "StudentNumber='" & Text1.Text & "'"
If Not Data1.Recordset.NoMatch Then
Text1.Text = Data1.Recordset![StudentNu mber]
Text2.Text = Data1.Recordset![StudentIC ]
With Data1.Recordset
If Not Data1.Recordset.EOF Then
DBGrid1 = Data1.RecordSource
End If
End With
End If
End Sub
but, my problem is the DBGrid only show the first time entering StudentNumber only.
for example:
i enter StudentNumber for the first time : AH970001
the DBGrid show all the AH970001 data.
but when i enter StudentNumber for the second time: AH 970031
the DBGrid still show the AH970001 data.
ooppss..
i put this coding in my Form1
Form2.Show vbModal
Form2.Text1.Text=Text1.Tex
is there any wrong here?
could anybody teach me on how to settle this problem?
i appreciate any help!
thanks in advance.
Private Sub Form_Load()
Dim MySQL As String
Dim Log As String
Dim db As Database
Text1.Text = Form1.Text1.Text
Set db = DBEngine(0).OpenDatabase("
MySQL = "SELECT * FROM QStudentSubject where StudentNumber='" & Text1.Text & "'"
Data1.RecordSource = MySQL
Data1.Refresh
Log = "StudentNumber='" & Text1.Text & "'"
If Not Data1.Recordset.NoMatch Then
Text1.Text = Data1.Recordset![StudentNu
Text2.Text = Data1.Recordset![StudentIC
With Data1.Recordset
If Not Data1.Recordset.EOF Then
DBGrid1 = Data1.RecordSource
End If
End With
End If
End Sub
Try rebinding when you refresh
ASKER
i don't know how to rebind and the comment is so short.
dbgrid1.rebind
dgbrid1.refresh
do that whenever you change the recordsource. i might have them backwards (might be refresh before rebind)
dgbrid1.refresh
do that whenever you change the recordsource. i might have them backwards (might be refresh before rebind)
Davehermann
you are relatively new to this site so I would ask you to please read the guidelines on comments vs answers at the bottom of this page and on https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
It is not considered good practice to lock questions in this way, as this places these questions in the locked section and reduces the visibility of the question to other experts. It also tends to put pressure on the questioner to accept the proposed answer. In future, please do not post "answers" except in trivial questions which have one and only one answer such as what is 1+1. I know that is a bit simplistic but I am sure you get the idea.
Having said that I hope that you continue to contribute to this site and that your experience proves useful to many others in future.
I am also rejecting your answer, for above reasons.
arnab79,
This does not mean that thi comment is not valuable, it still can be accepted as an answer.
costello
Community Support Moderator @ Experts-Exchange
you are relatively new to this site so I would ask you to please read the guidelines on comments vs answers at the bottom of this page and on https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
It is not considered good practice to lock questions in this way, as this places these questions in the locked section and reduces the visibility of the question to other experts. It also tends to put pressure on the questioner to accept the proposed answer. In future, please do not post "answers" except in trivial questions which have one and only one answer such as what is 1+1. I know that is a bit simplistic but I am sure you get the idea.
Having said that I hope that you continue to contribute to this site and that your experience proves useful to many others in future.
I am also rejecting your answer, for above reasons.
arnab79,
This does not mean that thi comment is not valuable, it still can be accepted as an answer.
costello
Community Support Moderator @ Experts-Exchange
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks to both dave and costello for trying to help me! :)
i appreciate it very much!
i'll try both of your suggestion now!
but, can i ask again if i still got problem?
i appreciate it very much!
i'll try both of your suggestion now!
but, can i ask again if i still got problem?
ASKER
oh, thanks to JackOfPH ! :) :)
thanks for elaborating the suggestion for me!:)
i appreciate it very much!
thanks for elaborating the suggestion for me!:)
i appreciate it very much!
ASKER
hi everybody :)
i've tried Dave's and Jack's suggestion.
it worked!!!!
i'm happy! thank you!
i've tried Dave's and Jack's suggestion.
it worked!!!!
i'm happy! thank you!