quixote

  • Thread starter No Current Record error 3021
  • Start date
N

No Current Record error 3021

Looking for suggestions on how to handle Run-Time error
3021 "No Current Record". This is generated when the
recordset being callled is empty. It happens on
rst.movefirst within vba code. Any suggestions? Looking
for proper syntax to basically say: If the recordset is
empty then exit sub.

Thanks
 
F

Frank Stone

If rsName.EOF Then
rsName.close
exit sub
else
rsName.movefirst
more code
end if
sorry, i wasn't finished with the first. hit the wrong keys
 
J

John Vinson

Looking for suggestions on how to handle Run-Time error
3021 "No Current Record". This is generated when the
recordset being callled is empty. It happens on
rst.movefirst within vba code. Any suggestions? Looking
for proper syntax to basically say: If the recordset is
empty then exit sub.

Thanks

Why not just trap the error and exit?

On Error GoTo Proc_Error
<your code here>
Proc_Exit:
Exit Sub
Proc_Error:
Select Case Err.Number
Case 3021 ' No current record
Resume Proc_Exit
<other handled cases>
Case Else
MsgBox "Error " & Err.Num & " in <procedurename>" _
& vbCrLf & Err.Description
Resume Proc_Exit
End Select
End Sub


John W. Vinson[MVP]
(no longer chatting for now)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top