[AccessD] ADHB2K - frmMultiPickMSForms <SOLVED>

John Colby jcolby at colbyconsulting.com
Fri Oct 10 08:23:13 CDT 2003


>John, thanx for this incredible explanation. Can I ask you something? Do
you walk around in a magical cloak?

LOL.  As the saying goes, we all stand on the shoulders of giants.

The shoulders I stand on are my Russian friend Shamil's.  I knew nothing of
Withevents until I started listening to little hints that Shamil would drop
in the list several years ago.  Shamil was truly one of the pioneers in
using Withevents, before him there was damned little published on the
subject.

I went to his web site and studied his code examples, and eventually, after
about the third attempt at understanding it, it all just clicked.  In my
case I never used classes (with Access) and you can't use WithEvents without
using Classes so I had to figure out the "why would you use classes" as well
as the "How do you use Withevents".

BTW, there are Withevent demos on the www.DatabaseAdvisors.com web site.  Go
to the newsletters page, then look in:

http://www.databaseadvisors.com/newletters/newsletter092001.htm
The newsletter "Adding a treeview control" for the article "TextBox Class"

http://www.databaseadvisors.com/newletters/newsletter112001.htm
The newsletter "Color matching in forms" for the article "Form class demo"

http://www.databaseadvisors.com/newletters/newsletter022002.htm
The newsletter "Binary bits and bytes" for the article "Creating a record
selector class"

and finally

http://www.databaseadvisors.com/newletters/newsletter052002.htm
The newsletter "What's That Form" for an article I wrote on "combining
Withevents and Raiseevents".

That should give you a little info to get you started using Withevents (and
RaiseEvents).

Good luck and enjoy.  Withevents are really cool stuff that let you do
things that could be difficult to do otherwise.

John W. Colby
www.colbyconsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Sad Der
Sent: Friday, October 10, 2003 1:56 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] ADHB2K - frmMultiPickMSForms <SOLVED>


....and then there was silence!
John, thanx for this incredible explenation. Can I ask
you something? Do you walk around in a magical cloak?
:-)

Once again thanx for you're detailed answer. I've got
some new stuff to try. This is why I love this list!

Regards,

Sander

--- John Colby <jcolby at colbyconsulting.com> wrote:
> SD,
>
> I have just finished taking this stuff (from adh 97
> apparently) and turning
> it into a class.  In my case I use Withevents which
> means that the events
> for the controls are handled right inside of the
> class.  It appears that
> this is probably how this (your) version works as
> well.
>
> Withevents is a keyword used with a dim statement
> for controls.  The syntax
> looks like:
>
> Private WithEvents mcmdAddOne As CommandButton
>
> The Withevent keywords can only be used in a class,
> which the form module is
> by the way.  Withevents says essentially, "this
> control is dimensioned 'with
> its events' being handled in this class".
>
> Once you dimension a control in this manner, then
> when an event for that
> control fires, control CAN be passed to code in your
> class.  I stress the
> word CAN because it won't necessarily be done.  In
> order for control for a
> given event to be passed to your class, the event
> stub has to be present in
> the class AND the exact text "[Event Procedure]" has
> to be present in the
> corresponding control event property.
>
> Any Access developer who programs the events for
> forms or controls is
> already familiar with these restraints, although you
> may not have ever
> thought about them.  When you want to use some
> event, you usually dbl-click
> in the form or control's property.  Let's take a
> command button as an
> example.
>
> You dbl-click in the "On Click" property of the
> control.
> The words "[Event Procedure]" magically appear in
> the property.  Nothing
> else has happened so far.
> You click on the ellipsis off to the right of the
> event.
> You are magically transported to the code editor and
> the following text is
> magically inserted into the form's module (which
> remember is a class).
>
> Private Sub cmdOK_MouseDown(Button As Integer, Shift
> As Integer, X As
> Single, Y As Single)
> End Sub
>
> Remember I said that in order for control to be
> passed to a class you had to
> have three things.
>
> 1) The control dimensioned "Withevents".
> 2) The exact text "[Event Procedure]" inserted in
> the event property of
> interest in the control.
> 3) An event stub inserted in your class to gain
> control of (sink) the event
> when it fires.
>
> In essence the wizard behind the property box takes
> care of doing these
> three things for you.
>
> One thing to note here is that ALL controls (and the
> form itself) are
> automatically "dimmed withevents" in a form's class
> module, i.e. it doesn't
> have to be explicitly done.  In YOUR classes it will
> have to be done!
>
> Once these three things are done, then when THAT
> event fires, control will
> eventually be passed to your class and you can do
> whatever you want inside
> that event stub.
>
> So that my friend is Withevents, and that is
> probably why you don't see any
> event handlers as you are accustomed to seeing in
> the form's class.  If you
> don't understand this stuff, LEARN IT.  It will take
> your Access abilities
> to a whole new level.  It's very easy to use and
> opens up a whole new world
> of possibilities in your applications.
>
> John W. Colby
> www.colbyconsulting.com





More information about the AccessD mailing list