raise form events programmatically

  • Thread starter Thread starter Eric G
  • Start date Start date
E

Eric G

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
 
No need to raise an event: just call the procedure

Dim intCancel As Integer

Call Form_Delete(intCancel)
 
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
 
Back
Top