|
-
May 25th, 2001, 03:55 PM
#1
Thread Starter
Lively Member
Error 3021
Im getting the following error
"3021 Either BOF or EOF is True, or the current record has been deleted.Requested operation requires a current record."
----------
This is my code
With rs
.Open strSQL, cn, adOpenDynamic, adLockOptimistic
.Delete
End With
rs.MoveNext
If rs.EOF Then
rs.MoveLast
End If
----------
I thought I took care of this error with the movenext and rs.eof check. What did I do wrong?
Thanks,
coopetj
-
May 25th, 2001, 04:32 PM
#2
Lively Member
I think that before you delete a certain record within a recordset, that record have to be the current one. You invoked the deletion before positioning on a particular record. So, assuming that you want to delete the first record, you should do that :
Code:
With rs
.Open strSQL, cn, adOpenDynamic, adLockOptimistic
.MoveFirst
.Delete
End With
But if you want to delete some other record than the first one, then you move to that record and only after you did that you call the deletion.
I hope this did help.
Surgeon
-
May 25th, 2001, 10:12 PM
#3
Well ...
Also check for the .EOF and .BOF before you try to delete any records, in this way you will be saved if the recordset is empty.
'Open recordset
'If BOF and EOF both true, the recordset is empty, so get the hell out of here.
'Recordset is not empty, so move to the desired record
'Delete the record.
.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|