View Full Version : no current record


qwkslvr1999
06-28-2002, 12:33 PM
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.

Alexandre
06-28-2002, 12:50 PM
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

qwkslvr1999
06-28-2002, 01:12 PM
thanks! i'll try that.