3021 error on delete record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access 2002: I have a delete button on my form, and it includes this line to perform the actual delete

DoCmd.RunCommand acCmdDeleteRecor

I am getting a "No current record (error 3021)" error that occurs at this line in my code ONLY when the record being deleted is the last one on the form; it does not happen if I choose a record other than the bottom record. It does delete the record, however. It happens on all forms that use this command (and this is a routine I use on virtually every form). If I turn on my record selectors & delete the record by selecting it and pressing the "Delete" key on the keyboard, it deletes without the error

This just started after my hard drive failed and I had to reinstall Windows XP Pro and Office XP Pro. All Windows & Office updates have been applied, however. I have Jet SP 4.0.8015. This occurs even after a Compact/Repair and whether I convert this to Access 2000 or 2002.
 
Are you sure that the cursor is not positioned on the unsaved blank new
record at the end of the form, when you run that code?

HTH,
TC


Brian said:
Access 2002: I have a delete button on my form, and it includes this line to perform the actual delete:

DoCmd.RunCommand acCmdDeleteRecord

I am getting a "No current record (error 3021)" error that occurs at this
line in my code ONLY when the record being deleted is the last one on the
form; it does not happen if I choose a record other than the bottom record.
It does delete the record, however. It happens on all forms that use this
command (and this is a routine I use on virtually every form). If I turn on
my record selectors & delete the record by selecting it and pressing the
"Delete" key on the keyboard, it deletes without the error.
This just started after my hard drive failed and I had to reinstall
Windows XP Pro and Office XP Pro. All Windows & Office updates have been
applied, however. I have Jet SP 4.0.8015. This occurs even after a
Compact/Repair and whether I convert this to Access 2000 or 2002.
 
Surprised this occurs in Access 2000, but other users have reported the same
issue after installing SP3 on Access 2002.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Brian said:
Access 2002: I have a delete button on my form, and it includes this line to perform the actual delete:

DoCmd.RunCommand acCmdDeleteRecord

I am getting a "No current record (error 3021)" error that occurs at this
line in my code ONLY when the record being deleted is the last one on the
form; it does not happen if I choose a record other than the bottom record.
It does delete the record, however. It happens on all forms that use this
command (and this is a routine I use on virtually every form). If I turn on
my record selectors & delete the record by selecting it and pressing the
"Delete" key on the keyboard, it deletes without the error.
This just started after my hard drive failed and I had to reinstall
Windows XP Pro and Office XP Pro. All Windows & Office updates have been
applied, however. I have Jet SP 4.0.8015. This occurs even after a
Compact/Repair and whether I convert this to Access 2000 or 2002.
 
The cursor is on the last record. In fact, I inserted a Msgbox to display the content of the current field on the line immediately preceding the acCmdDeleteRecord, and it correctly shows the current record & field content. When I move it to the line after the acCmdDeleteRecord, it is preempted by the error and never displays the Msgbox

When I try to delete a new record (bypassing my code that prevents this), I correctly get a 2046 error, which indicates that DeleteRecrod action is not currently available

The error occurs even if I select the record using the record selector and then use my programmatic delete button acCMdDeleteRecord in code); it does not occur if I use the Delete button on the keyboard

This was all working fine until I got a new hard drive, reinstalled the OS (Win XP Pro) & Office XP Pro with all current SP's. Now it happens for ALL forms that use this deletion method, so it is not a problem with a single control.
 
This is Access 2002, but the problem occurs whether the DB is saved in Access 2000 or Acess 2002 format. Is there a post-SP3 fix for this?
 
I just talked to MS tech support - this is a bug in SP3 that has not yet hit the knowledgebase. Their workaround was to trap the 3021 error & resume next (as if I didn't already knew that...). They were not sure if/when a hard fix would be issued.
 
Back
Top