"Robert" <pr**********@yahoo.com> wrote in message
news:3Q******************@fe02.lga
I have a label on my form lblCount and the following code in my form for
displaying a record count:
Private Sub Form_Current()
Me.RecordsetClone.Bookmark = Me.Bookmark
Me!lblCount.Caption = Me.RecordsetClone.AbsolutePosition + 1
End Sub
It works fine until I page to the last record and I get:
Run-time Error 3021, No Current Record
How to fix?
Robert
It work fine until you don't click NewRecord when you are at
last or Previous when you are at first...!!!
You lose Error gestion...?
First you know that when you go to next when you
are at last the Absolute position give error, but
the label need to show some value.
This value is the RecordCount+1, but only if you
are on NewRecord, in the other case, if err.Number=3021
you need Resume Next.
Try with this, i write it without test, so good work.
Private Sub Form_Current()
On Error Goto Err_Get
Me.RecordsetClone.Bookmark = Me.Bookmark
Me!lblCount.Caption = Me.RecordsetClone.AbsolutePosition + 1
Err_Gest:
If Err.Number=3021 then
If me.NewRecord then
Me!lblCount.Caption=Me.RecordsetClone.RecordCount+ 1
Else
Resume Next
End if
Else
msgbox Err.Number & " " & err.Description
End if
Exit sub
@Alex
--
Posted via Mailgate.ORG Server -
http://www.Mailgate.ORG