[AccessD] Trapping Events In A Class (custom events as well as built-in)

Michael Mattys michael at mattysconsulting.com
Wed Aug 8 09:37:58 CDT 2012


Having worked through the material on Shamil's site in 2000,
I recall that the new class had to have these elements:

Private WithEvents Form As Access.Form
Private mcolControls As New Collection
Private mobjSelfRef As Object

and then all of the other controls and such.

It seems like "Private mobjSelfRef As Object" was critical for some reason?
Or am I remembering incorrectly?

Michael R Mattys
Mattys Consulting, LLC
www.mattysconsulting.com


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Wednesday, August 08, 2012 10:12 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Trapping Events In A Class (custom events as well as
built-in)

And I do it differntly still.  My class accepts a form as an argument in
it's init routine, which is called from the form.  The form declares a
variable mFrm as New clsForm and then instantiates the variable  like this:

mFrm.init Me

We all seem to approach it from a slightly different angle depending on what
we want to do.

Charlotte

On Wed, Aug 8, 2012 at 4:43 AM, A.D. Tejpal <adtp at airtelmail.in> wrote:

>     It is observed that for trapping custom events raised in a form, 
> WithEvents pointer in a new class needs to be declared as that form's 
> class object, as per sample statement below:
>
> ' Sample code in class module
> '==============================
> Private WithEvents mfm As Form_MyForm
> '==============================
>
>     However, the resulting object does not expose built-in events of 
> the form (like Load, Current etc).
>
>     On the other hand, declaring it as Access.Form makes available all 
> the normal events of a form but not the custom events.
>
>     For getting access to both sets of events, it is found necessary 
> to set up two separate pointers, one as Access.Form and the other as 
> Form_MyForm.
>
>     Could there be a better course of action?
>
> Best wishes,
> A.D. Tejpal
> ------------
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
>
>
> Website: http://www.databaseadvisors.com
>
>
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list