[AccessD] ribbon context

John Colby jwcolby at gmail.com
Fri Jan 28 12:32:03 CST 2022


1) In the class header, Dim a variable that will hold a pointer to a form.

private WithEvents frm as form

That tells the class that you are expecting the passed in object (the form
in this case) to raise events.

2) Pass in a pointer to the form (me) to the class you are instantiating in
the form.
3) Save that pointer to me in the frm variable in the header.

Now the class can sink any and all events for the form passed in.

Understand that the class can raise events.  If you want to to sink events
raised by the class back in the form, simply dimension the clsFrm variable
WithEvents back in the CBF.l  However you MUST actually declare events you
intend to raise inside clsFrm or the compiler will complain  that clsFrm
doesn't raise any events.

AFAIK you don't have to actually RAISE said events, but you have to declare
these events to be raised up in the class header or the compiler will think
the clsFrm doesn't raise events and refuse to compile.

Also remember that an event can be sunk in more than one place.  If you
create an event handler in the form's CBF and also in clsFrm then (I
believe) control will first go to the event sink in the form's native CBF
and once that event sink exits control will be passed to the event sink in
the clsFrm.

This allows you flexibility to do some processing in the form then do more
processing in clsFrm.  Not often used but possible.  Or you can not create
the event sink in CBF, just sink the event in clsFrm, immediately raise an
event sunk in the CBF, and when control returns, continue processing in
clsFrm.

Lots of useful stuff can be done.

On Fri, Jan 28, 2022 at 10:40 AM Ryan W <wrwehler at gmail.com> wrote:

> Yes I am using your class modules.  Just wondering if I can tie in
> OnActivate/OnDeactivate ... problem is I don't have every form in my FE
> instantiating an instance of the class right now.
>
>
> On Fri, Jan 28, 2022 at 9:22 AM John Colby <jwcolby at gmail.com> wrote:
>
> > OnOpen of the form event.
> >
> > Dim the class object in the header, create an instance in the OnOpen and
> > store it in that variable you created in the form header.  Then do
> whatever
> > the class is supposed to do.
> >
> > As an example, I had a clsForm which I used to scan for all my controls,
> > loading an instance of a class wrapper for each control found for which I
> > had written a class.  For example combos, text boxes, tab controls and
> > subforms (for JIT subforms) etc etc.
> >
> > On Thu, Jan 27, 2022 at 10:06 PM Bill Benson <bensonforums at gmail.com>
> > wrote:
> >
> > > Got it. I doubt highly that you can do what you are aiming to do
> because
> > a
> > > form has to be instantiated before its object properties and events are
> > > “live”.
> >
> >
> > --
> > John W. Colby
> > Colby Consulting
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
John W. Colby
Colby Consulting


More information about the AccessD mailing list