Re: Runtime Error 3021 BOF EOF
Code:
If Not rs.BOF And rs.EOF Then
If both BOF and EOF is true as would be the case in your else senario then there are no records in the recordset therefore there is no first or last to move to and it is giving you an error.
What you need in your else is something more like.
Code:
Msgbox "Record not found"
Edit: On another note you should be closing your recordset outside the If block. as is it is only closing the recordset when the If condition is true. moving the close statement after the end if will close it in either case.
Last edited by DataMiser; August 13th, 2011 at 09:02 AM.
Always use [code][/code] tags when posting code.