[AccessD] Demo sinking events in two places

jwcolby jwcolby at colbyconsulting.com
Thu Feb 12 13:10:57 CST 2009


Hey, that is a good catch.  And good application of the theory.

My problem is I know this stuff too well, which leads to slips.

I THOUGHT I had sent an email where I had you create an event sink in frmDemoCtls for that command 
button control.  If not, then in frmDemoCtls paste the following code:

Private Sub Command15_Click()
     MsgBox Me.Name & ": command15 Click"
End Sub

By the way, TYPING in the code into the form class does not "hook" the event for the command button, 
whereas cutting and pasting that code in DOES hook the command button event, i.e. adds the "[Event 
Procedure]" to the click property of the command button.

I mentioned that once somewhere in a past lecture, but it bears repeating for those who like to type 
stuff in for the practice.

Isn't it cool though that a control on this form can directly cause code on that form to execute? 
The power of Events!

John W. Colby
www.ColbyConsulting.com


McGillivray, Don [IT] wrote:
> OK, I know I'm WAY more jazzed by this than I should be, but after following your instructions, the forms failed to behave as advertised.  So, pulling together what we've learned so far, I dug into the code, and uncovered a small but significant omission.  In the Form_Load event of the "...Sinking..." form, The reference to the "...Demo..." form's command button was established, but the OnClick event wasn't "hooked" by setting its value to [Event Procedure].  Inserted this line in the Form_Load event's code:
> 
> Cmd.OnClick = [Event Procedure]
> 
> and it worked.
> 
> I AM getting this . . .   :o)




More information about the AccessD mailing list