I have problem when open the record set as below code :
Private Sub Text4_LostFocus ()
Dim dbs As Database
Dim rs As Recordset
Dim sql As String
On Error Resume Next
Set dbs = CurrentDb()
sql = "select * from tbl_InsertPictu re where pname = '" & Text4 & "'"
Set rs = dbs.OpenRecords et(sql)
rs.MoveLast
rs.MoveFirst
Text8 = rs.RecordCount
Text6 = rs!card
rs.Close
End Sub
Data in Table tbl_InsertPictu re
ID card fname lname
1 31001 A X1
2 31002 B X2
3 31005 C X3
4 31009 D X4
5 31100 B X5
6 31111 C X6
Text4 serch the name "C", in form show text6 = 31005 and text8 = 2 that but when I click next on the navigator button form still show text6 = 31005 but acctually text6 have to show 31111, I don't understand why the record are not able to move to other records.
Please help me, what wrong on my code and how to solve this problem.
Thank you very much.
Private Sub Text4_LostFocus ()
Dim dbs As Database
Dim rs As Recordset
Dim sql As String
On Error Resume Next
Set dbs = CurrentDb()
sql = "select * from tbl_InsertPictu re where pname = '" & Text4 & "'"
Set rs = dbs.OpenRecords et(sql)
rs.MoveLast
rs.MoveFirst
Text8 = rs.RecordCount
Text6 = rs!card
rs.Close
End Sub
Data in Table tbl_InsertPictu re
ID card fname lname
1 31001 A X1
2 31002 B X2
3 31005 C X3
4 31009 D X4
5 31100 B X5
6 31111 C X6
Text4 serch the name "C", in form show text6 = 31005 and text8 = 2 that but when I click next on the navigator button form still show text6 = 31005 but acctually text6 have to show 31111, I don't understand why the record are not able to move to other records.
Please help me, what wrong on my code and how to solve this problem.
Thank you very much.
Comment