Can you capture an event for ref in the code of the next event

G

Guest

I want to determine whether the event immediately preceeding a button click
was the selection or click on a specific record in a continous form.

The importance of determining the immediate predecessor event is I don't
want the user to be able to delete the current record unintentionally by
clicking delete.
 
G

Guest

Set your form's AllowDeletions property to No. In your button's code, preceed
the delete statement with:
Me.AllowDeletions=True
and set it back after the record's been deleted with
Me.AllowDeletions = False

This should force the user to use the button to do deletions.

Barry
 
J

John Nurick

Hi Sisyphus,

If you click on a record in a continuous form, that becomes the current
record. Does that answer the question?
 
G

Guest

I guess I wasn't clear. The problem is the button deletes the current
record. But I only want the button to work when the user clicks it while in
a record - indicating that is the record they want to delete.
 
J

John Nurick

In general, a bound form that is ready to receive a button click always
has a current record (there are exceptions such as when the recordset is
empty). In other words the user is always "in a record".

So the only way to do what you seem to have in mind is to maintain a
module-level boolean variable in the form (let's call it CanDelete) and
use the Click and Enter events of the form and every control on it to
set and clear CanDelete according to whether you consider the user is
"in a record".

IMHO a much more friendly approach would be to use the form's
BeforeDelConfirm event to display a custom message identifying the
record that is being deleted. One way to do this is to

1) have module-level variables for fields (e.g. LastName, FirstName)
that will adequately identify the record to the user.

2) update these variables in the form's Current event procedure.

3) in the form's BeforeDeleteConfirm() event procedure, use a messagebox
that displays the values of the variables and asks the user to confirm
deletion of that record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top