[AccessD] USING CLSMSGDEMO

jwcolby jwcolby at colbyconsulting.com
Sat Feb 14 06:43:43 CST 2009


Arthur,

We could have checked any of the variables, it doesn't matter which.  Once initialized the variables 
will stay initialized until they are set to nothing somehow.  I just use the If Var is nothing 
syntax because it is fairly fast code and tests the actual variable we care about.  In this case, if 
one is set, the others will be too since there is no way to clear just one at a time.

Arthur, I am impressed!  Individually these lectures were pretty short and sweet, but there were a 
lot of them and it takes effort to keep with it.  That last lecture will probably take some time for 
many folks to work through and really understand the code jumping around.

I like your "Office chatter".  I often use a function like that down in the bottom of the 
initialization module exactly as a test harness, just so that I don't have to keep typing stuff into 
the debug window.

Was it you who wanted to keep an invoice form synced to a customer form?  Now you have a message 
channel to use to keep the forms synced.  Set up mclsMsg in the header of the Customer form. 
frmCustomer will then send messages in OnCurrent, in other words every time you move through the 
records, send a message saying "I changed records".  In the from, send me.Name, Leave "To" blank 
(any form might want to process the messages).  In Subject put "CustomerID", and in Msg put the 
actual long integer that is the customer PKID.

Now over in frmInvoice, dim Withevents mclsMsg.  Sink the message event.  In the message sink, do an 
"if From = 'frmCustomer' then" and process messages from frmCustomer.  When a message comes in with 
CustomerID in the Subj, take the CustomerID in the Msg and use it to filter the form to just records 
for that customer.

Dead simple now that you understand classes and sinking events.  You have a message class to use as 
the message channel.

Fun stuff!

John W. Colby
www.ColbyConsulting.com


Arthur Fuller wrote:
> This one was really fun! I have one question, though. I think that I already
> know the answer but want to make sure. The code...
> 
> Function mDemoMsgInit()
>     If mclsDemoMsgSteve Is Nothing Then
>     ...
> 
> Do we check mclsDemoMsgSteve because Steve was the first instance created?
> 
> I created a little test harness I call OfficeChatter.
> 
> Sub OfficeChatter()
>     cDemoMsgGeorge.mSendMsg "Linda", "Lunch Today", "After the meeting we
> will all be meeting for lunch at the deli one building over."
>     cDemoMsgLinda.mSendMsg "Steve", "Tuesday's meeting", "Sorry, Steve. I
> won't be able to attend the meeting."
>     cDemoMsgGeorge.mSendMsg "John", "Lunch Today", "After the meeting we
> will all be meeting for lunch at the deli one building over."
>     cDemoMsgLinda.mSendMsg "George", "Lunch Today", "Whew! I got out of
> Steve's meeting. It would be as exciting as watching paint dry."
> End Sub
> Clear all the breakpoints and run it, and you'll see why I named it that.
> 
> Where's my diploma, teach? :)
> 
> Arthur



More information about the AccessD mailing list