Delete Record Command Button

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

Guest

I created my database in Access 2000 and my company recently upgraded to
2002. Certain people are still using 2000 in my organization however so I
don't want to convert my db yet.

Problem: I have a button on a form that the button wizard set up to delete
a record. Previously it worked fine.

While it still deletes the active record on my form, it now also gives an
error message that says "No current record." This appears after the record
is deleted.

The VBA code that the wizard created is:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

I know those numbers refer to Access 95 commands but I don't know what they
are. I still haven't figured out VBA very well...

Curiously, if I select Delete Record from the menu, the error message
doesn't appear so the code is not the same.

How can I stop that error message from appearing?
Thanks
 
This is a known problem with Access 2002 SP3. This particular version/patch
reports the "No Current Record" error immediately after the deletion, and
then sorts itself out again quickly.

Temporarily comment out the error handler, and get the actual number for the
error. Then change the error handling part of the routine so it just ignores
this error, i.e.:
If Err.Number <> xxxx Then
MsgBox ...
End If

What the wizard code does is fire off the 9th item on the Edit menu in A95
(the first record is zero), which is Select Record. Then it fires the 7th
item on the Edit menu, which is the Delete.

A better way to code this would be:
RunCommand acCmdDeleteRecord
However, I suspect this will still strike the same bug in this
version/patch.
 
Thanks! That worked great. I had tried playing with the command and using
the newer RunCommand but it still generated the error.

But your code fixed the problem.
 
I am trying to use code containing acCmdDeleteRecord, with a command as in
the post "creating FORM delete button". I get error 3709, "the search key
was not found in any record". The appropriate record is deleted ok, but I
cannot persuade Access 2002 to quit issuing the error message. I tried
blanking it out with your code below, but I need more details on the MsgBox
part. Obviously, I am not a real programmer.
 
Back
Top