From: Eric G Eric on
Is it possible to raise built-in form events programmatically? I have a
feeling it isn't but thought I would check.

For instance, I want to do something like this within a private sub on the
form:
RaiseEvent Delete(Cancel)

and have it trigger the Access.Form delete event -- i.e. without actually
deleting a bound record.

Note my delete event is not handled by the form itself but by an external
class, so I can't simply call Form_Delete(Cancel).

Thanks,
Eric
From: Douglas J. Steele on
No need to raise an event: just call the procedure

Dim intCancel As Integer

Call Form_Delete(intCancel)

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"Eric G" <Eric G(a)discussions.microsoft.com> wrote in message
news:A7C18BD6-38A4-411E-ADD4-5D178034ABD3(a)microsoft.com...
> Is it possible to raise built-in form events programmatically? I have a
> feeling it isn't but thought I would check.
>
> For instance, I want to do something like this within a private sub on the
> form:
> RaiseEvent Delete(Cancel)
>
> and have it trigger the Access.Form delete event -- i.e. without actually
> deleting a bound record.
>
> Note my delete event is not handled by the form itself but by an external
> class, so I can't simply call Form_Delete(Cancel).
>
> Thanks,
> Eric


From: Eric G on
Thanks - but that's the problem. My event is not handled by the form itself
but by an external class, so I can't simply call Form_Delete(Cancel). There
is no such sub "Form_Delete". It's handled by a callback in a class, e.g.
frm_Delete where frm is bound to the form. So I think I do need to raise the
event to get it to be handled.

The larger context is what I would think would be a common situation. You
have a 'continuous-forms' form listing all your entities, which is bound to a
query that might not allow you to delete the underlying records - it might
involve outer joins, etc. So you have to do the deletion 'outside' the form
recordset, running a delete query or DAO or whatever. But you still want to
be able to use the standard Access delete-confirmation process, i.e.
Delete/BeforeDelConfirm/AfterDelConfirm, or something very similar to it,
while providing your own code for doing the actual deletion.

In my project, the delete- (and update-) confirmation process is handled in
a consistent way for all forms using custom classes (which do the validation,
logging, confirmation, error handling, etc.) But to work, they depend upon
the standard Access form events being raised.

At the moment I'm working around it by leaving the deletion to forms that
are bound to delete-able recordsets, but it would be good to know how others
have dealt with similar situations.

Thanks,
Eric

"Douglas J. Steele" wrote:

> No need to raise an event: just call the procedure
>
> Dim intCancel As Integer
>
> Call Form_Delete(intCancel)
>
> --
> Doug Steele, Microsoft Access MVP
> http://www.AccessMVP.com/DJSteele
> (no e-mails, please!)

From: Eric G on
I found a workaround I'm happy with, for anyone searching this later.

Basically, it involves making the form a subform of another form that is
bound to a recordset that can be deleted from. So the deletion can be done in
the outer form using the standard Access form events, based on the selection
in the inner form.

More at
http://stackoverflow.com/questions/2804742/ms-access-raise-form-events-programmatically