Is it possible to know what button the user has clicked on?

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

Guest

Hi all!

I would like to put code in an on current event that doesn't run when the
event is triggered because the record is being deleted. Is there a way that
I can look at what the user did to trigger the on current event? I'd be
happy with some general suggestions and key terms that I can look up on my
own.

Thanks!
Andrea
 
Hi Andrea

There are usually a number of ways to delete a record, and a number of
things that can cause the deletion to be cancelled, so I think you would be
better to use the events related to the actual deletion to detect that the
delete is happening.

These are:
DeleteBeforeDelConfirm
<<<
AfterDelConfirm

It is only in AfterDelConfirm that you actually know for sure that the
record has been deleted, but unfortunately the record is "semi-deleted"
BEFORE the delete confirmation, so the Current event fires at the >>> point
above. If the delete is cancelled then the record is restored and the
Current event fires again at <<<.

You probably want your code to be skipped for both these calls to
Form_Current, so I suggest you declare a module-level boolean flag:
Dim mfDeleteInProgress as Boolean

Then, you can set this to True in Form_Delete and back to False in
Form_AfterDelConfirm.

In Form_Current, check its state to see if you should run or skip your code:
If Not mfDeleteInProgress Then
...
End If
 
Graham Mandeno said:
Hi Andrea

There are usually a number of ways to delete a record, and a number of
things that can cause the deletion to be cancelled, so I think you
would be better to use the events related to the actual deletion to
detect that the delete is happening.

These are:
Delete
BeforeDelConfirm
<<<
AfterDelConfirm

It is only in AfterDelConfirm that you actually know for sure that the
record has been deleted, but unfortunately the record is
"semi-deleted" BEFORE the delete confirmation, so the Current event
fires at the >>> point above. If the delete is cancelled then the
record is restored and the Current event fires again at <<<.

You probably want your code to be skipped for both these calls to
Form_Current, so I suggest you declare a module-level boolean flag:
Dim mfDeleteInProgress as Boolean

Then, you can set this to True in Form_Delete and back to False in
Form_AfterDelConfirm.

In Form_Current, check its state to see if you should run or skip
your code: If Not mfDeleteInProgress Then
...
End If

Graham, please accept my congratulations -- this just struck me as an
absolutely perfect reply.
 
Back
Top