Error Message 3021 (1 Viewer)

hascons

Registered User.
Local time
Today, 06:43
Joined
Apr 20, 2009
Messages
58
Hello,

I've created an unbound form to for experimental purposes. I have navigation buttons to move to first,last,next,previous. I get an error message if I'm at the last record and hit the move next command button. I've been experimenting with EOF and BOF if statements But I keep getting the Error message 3021.

Am I missing something in my code?

Function UnBoundMoveNext(frm As Form) As Integer
Dim ctlName As String
Dim x As Integer

If rstEmployees.EOF = True Then

rstEmployees.MoveNext

'Cycle Through the Recordset Setting the Value of Each Control On Form
For x = 0 To rstEmployees.Fields.Count - 1
ctlName = rstEmployees.Fields(x).Name
frm.Controls(ctlName).Value = rstEmployees.Fields(x).Value
Next x
End If
End Function
 

SpentGeezer

Pure Noobism
Local time
Today, 23:43
Joined
Sep 16, 2010
Messages
258
I have a textbox which is locked and has the current record number in it. Then I use this to check if it is the last record:

If Not txt_record.Value = Me.Recordset.recordCount Then
DoCmd.GoToRecord , , acNext
txt_record.Value = txt_record.Value + 1
Else
MsgBox "This is the last Record", vbInformation, "Last Record"
End If
 

MarkK

bit cruncher
Local time
Today, 06:43
Joined
Mar 17, 2004
Messages
8,185
What is the error message? At what line does the error occur?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 14:43
Joined
Sep 12, 2006
Messages
15,708
you just need someting like

if rs.eof then
msgbox "No more records
exit sub
end if

if rs.bof then
msgbox "Already at Start"
exit sub
end if
 

Users who are viewing this thread

Top Bottom