gotonext record create runtime error '13' (type mismatch) (1 Viewer)

genesis

Registered User.
Local time
Today, 00:35
Joined
Jun 11, 2009
Messages
205
when I click the next button it state runtime error '13' type mismatch. I dont know what part of the code is wrong. previously it worked !
please help.

Private Sub next_Click()

Dim rec As Recordset
Set rec = Me.RecordsetClone

'Move recordset to current form record
rec.Bookmark = Me.Bookmark

rec.MoveNext

If rec.EOF Then
'At last record, move to first
rec.MoveLast
Me.Bookmark = rec.Bookmark
Else
'Next record exists, move to next
rec.MovePrevious
Me.Bookmark = rec.Bookmark
DoCmd.GoToRecord , , acNext
End If

End Sub
 

boblarson

Smeghead
Local time
Today, 00:35
Joined
Jan 12, 2001
Messages
32,059
Just use this code:

Code:
On Error GoTo err_hand

DoCmd.RunCommand acCmdRecordsGoToNext

ExitSub:
  Exit Sub

err_hand:
   If Err.Number = 2105 Then
      MsgBox "No record to move to.", vbExclamation
   Else
      MsgBox Err.Description, vbExclamation, "Error #: " & Err.Number
   End If
 

genesis

Registered User.
Local time
Today, 00:35
Joined
Jun 11, 2009
Messages
205
that was quick and simple Sir. actually it worked but I get error 2046 that RecordsGoToNext isnt available so I change the code a bit to

'===========================
On Error GoTo err_hand

DoCmd.RunCommand acCmdRecordsGoToNext

ExitSub:
Exit Sub

err_hand:

MsgBox "You have already reached the last record.", vbInformation, ""

'===========================

that already would meet my need.

thanks for the reply Sir. I badly needed that. Never thought of using runcommand statement. Thanks again Sir.
 

Users who are viewing this thread

Top Bottom