no current record

qwkslvr1999

Registered User.
Local time
Today, 14:17
Joined
Jan 21, 2002
Messages
42
I have the following that shows me which record I am curently viewing out of total records.


Dim Myrst As Recordset

Me.CurRec= Me.CurrentRecord


Set Myrst= CurrentDb.OpenRecordset("SELECT field1, field2 FROM tbl1 WHERE tbl1.field1='" & Forms!frminfo!field1 & "'")

Myrst.MoveLast
Me.totalrec = Myrst.RecordCount
Myrst.Close

Everything works fine for the first record. When I go to the next record, it gives me either of the errors: "No current record" or "You can't go to the specified record."

Any idea why? Thanks in advance.
 
I find strange your 'Me.CurRec= Me.CurrentRecord '
But apart from that, you should check if your query returned any record befor trying to use your recordset:

Me.CurRec= Me.CurrentRecord

Set Myrst= CurrentDb.OpenRecordset("SELECT field1, field2 FROM tbl1 WHERE tbl1.field1='" & Forms!frminfo!field1 & "'")
If Not Myrst.nomatch then
Myrst.MoveLast
Me.totalrec = Myrst.RecordCount
Myrst.Close
End if
 
thanks! i'll try that.
 

Users who are viewing this thread

Back
Top Bottom