On Delete event repeats

  • Thread starter Thread starter Brad P
  • Start date Start date
B

Brad P

An On Delete event on a subform repeats when I delete a record (when the
condition is true) in that subform. Here is the code:

If Me![Staff] <> Forms![frm_StaffInitials]![Initials] Then
MsgBox "You can not delete a Time Expense created by another user"
DoCmd.CancelEvent
Exit Sub
End If

Not sure why....any suggestions?

Thanks
 
The event should repeat if you selected two rows at once (in a continuous
form or datasheet).

If that's not the case, is there anything similar in the BeforeDelConfirm or
AfterDelConfirm events?

You could also try replacing:
DoCmd.CancelEvent
with:
Cancel = True
since the event provides a Cancel argument.
 
Allen Browne said:
The event should repeat if you selected two rows at once (in a continuous
form or datasheet).

Its only one record I select in a continuous form.
If that's not the case, is there anything similar in the BeforeDelConfirm or
AfterDelConfirm events?
Nothing.

You could also try replacing:
DoCmd.CancelEvent
with:
Cancel = True
since the event provides a Cancel argument.

Tried that suggestion, same thing. I know that the On Delete event itself
runs twice as I watched the code run.

I use the record selector on the form, hit the Delete key. I get my prompt
twice. Weird /-| haha

Thanks Allen for the reply
Brad
 
I tried opening the subform by itself and the Delete event ran once, so it
has something to do with it being a subform. Interesting.
 
Brad the only other suggestion I have is to check that you have the correct
service pack for your version of Access.

Help | About will give you your version number and service pack.
support.microsoft.com will take you to the latest service pack.
 
I have 9.0.4402-SR1.

I'm going to play around with it today, if I figure out what is going on, I
will post it.

Thankss
Brad
 
Back
Top