[AccessD] Your favorite control behavior

Jürgen Welz jwelz at hotmail.com
Sun Mar 7 00:08:40 CST 2004


That is almost exactly the way my Notinlist procedure is coded.  I also add 
two parameters, one for the target table to which the record will be added 
and one for a user name for the type of data to be added.  I guess the only 
difference is that I don't open a separate data entry form.  I just set a 
single record recordset for the existing form to the record that is added 
and it displays the new data in the appropriate field or fields.

For things like date fields or lookups, I create them once on a template 
form and then copy from there to the form on which I need it displayed.  
Although you can use WithEvents and hook up controls, I haven't found a way 
to do this with the Notinlist parameters.  I have found that just about 
every event that I may want to use WithEvents for, I can instead create a 
public function procedure for.  For a control that displays a date for which 
I want a calendar to pop on double click and to change backcolor when it 
gets focus and revert to a non-focus backcolor when focus is lost, or 
respond to mouse move events, I can call the public procedure, usually 
passing in screen.activecontrol by using the function name rather than 
[eventprocedure] in the property sheet.  When I copy and paste a date 
control from my template form into a new target form, it is completely 
hooked up to all standard events.  Retrieving the form container name only 
requires the code to check the parent property of the active control.  For 
example, if you open the event property sheet for a conventional textbox, in 
the On Got Focus entry in the property you could enter:

=OnFocus([Screen].[Activecontrol])

and in the On Lost Focus entyr you could enter:

=OffFocus([Screen].[Activecontrol])

Then in a public module:

Public Function OnFocus(ctl As Control)
    ctl.BackColor = vbWhite 'or some standard constant
End Function
Public Function OffFocus(ctl As Control)
    ctl.BackColor = -2147483633 'or some constant that can be set
End Function

You can check for control type being a combo and call .DropDown in the 
OnFocus or write a separate OnFocusCombo procedure.  The whole point is that 
the event procedures are hooked up  when you paste a copy of the control as 
the event properties are copied with the control.

Another nice means to hookup events automatically is to create a control 
combination, or even a single control, encapsulated on a sub form all by 
itself.  The control comes with its own class module in the code behind the 
subform.  I have found this a great way to hookup something like a callback 
based list of municipalities with a not in list that can be made aware of 
the need to requery the data array when there is an addition or change to a  
municipality record.  No need to create a new copy of the control on 
multiple forms, just drag the subform container on and you get format and 
events all done.

Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com





>From: "Arthur Fuller" <artful at rogers.com>
>Reply-To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>To: "'Access Developers discussion and problem 
>solving'"<accessd at databaseadvisors.com>
>Subject: RE: [AccessD] Your favorite control behavior
>Date: Sat, 6 Mar 2004 22:53:53 -0800
>MIME-Version: 1.0
>Received: from mc2-f12.hotmail.com ([65.54.190.19]) by mc2-s14.hotmail.com 
>with Microsoft SMTPSVC(5.0.2195.6824); Sat, 6 Mar 2004 19:56:23 -0800
>Received: from databaseadvisors.com ([209.135.140.44]) by 
>mc2-f12.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Sat, 6 Mar 2004 
>19:56:23 -0800
>Received: from databaseadvisors.com (databaseadvisors.com 
>[209.135.140.44])by databaseadvisors.com (8.11.6/8.11.6) with ESMTP id 
>i273tWM26752;Sat, 6 Mar 2004 21:55:32 -0600
>Received: from 
>fep03-mail.bloor.is.net.cable.rogers.com(fep03-mail.bloor.is.net.cable.rogers.com 
>[66.185.86.73])by databaseadvisors.com (8.11.6/8.11.6) with ESMTP id 
>i273tRM26707for <accessd at databaseadvisors.com>; Sat, 6 Mar 2004 21:55:27 
>-0600
>Received: from rock ([24.153.60.144])by 
>fep03-mail.bloor.is.net.cable.rogers.com(InterMail vM.5.01.05.12 
>201-253-122-126-112-20020820) with ESMTP 
>id<20040307035516.YGWF411419.fep03-mail.bloor.is.net.cable.rogers.com at rock>for 
><accessd at databaseadvisors.com>; Sat, 6 Mar 2004 22:55:16 -0500
>X-Message-Info: jl7Vrt/mfsqz8S4A4C6FS1y0F6nk0vr4
>Message-ID: <016a01c40410$f433f490$6501a8c0 at rock>
>X-MSMail-Priority: Normal
>X-Mailer: Microsoft Outlook, Build 10.0.2627
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>In-Reply-To: <DCEFJAOENMNENLAAOFGPGEFLHBAA.jwcolby at colbyconsulting.com>
>X-Authentication-Info: Submitted using SMTP AUTH LOGIN 
>atfep03-mail.bloor.is.net.cable.rogers.com from [24.153.60.144]using ID 
><artful at rogers.com> at Sat, 6 Mar 2004 22:55:16 -0500
>X-BeenThere: accessd at databaseadvisors.com
>X-Mailman-Version: 2.1.4
>Precedence: list
>List-Id: Access Developers discussion and problem 
>solving<accessd.databaseadvisors.com>
>List-Help: <mailto:accessd-request at databaseadvisors.com?subject=help>
>List-Post: <mailto:accessd at databaseadvisors.com>
>List-Subscribe: 
><http://databaseadvisors.com/mailman/listinfo/accessd>,<mailto:accessd-request at databaseadvisors.com?subject=subscribe>
>List-Archive: <http://databaseadvisors.com/pipermail/accessd>
>List-Unsubscribe: 
><http://databaseadvisors.com/mailman/listinfo/accessd>,<mailto:accessd-request at databaseadvisors.com?subject=unsubscribe>
>Errors-To: accessd-bounces at databaseadvisors.com
>Return-Path: accessd-bounces at databaseadvisors.com
>X-OriginalArrivalTime: 07 Mar 2004 03:56:23.0073 (UTC) 
>FILETIME=[27FAB110:01C403F8]
>
>I have a function called aaNotInList() which takes the same parms as the
>NotInList function and adds two new ones -- the name of the form to open
>when adding an item, and the "human" name of said entity, the latter
>just to pretty up the messagebox that comes up. The functon asks if you
>want to add a new "XXX" (4th parm) and if so opens the specified form,
>which uses the typical code to hide itself on OK and close itself on
>Cancel. Then the function does the usual "add to list and accept the
>value" and closes the form. It works great but I still have to type in
>that line of code every time I need one. Not that one line of code is a
>major hassle, I guess, but can you think of a class-based way to do
>this? It might be more fun to do it that way.
>
>Arthur
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com
>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John W. Colby
>Sent: Saturday, March 06, 2004 1:24 PM
>To: AccessD
>Subject: [AccessD] Your favorite control behavior
>
>
>I am taking suggestions for control behaviors that you have found useful
>and have programmed controls to perform in the past.
>
>For example I program the back color of combos, lists and text boxes to
>change to a given color as they get the focus, and back to their
>original color as they lose the focus.  This helps to avoid the "where's
>the cursor" questions.
>
>Another example, I program the double-click of a combo to open a form to
>allow editing the data in the table that the combo pulls from.  In
>addition, if a combo is programmed to perform this behavior, I
>dynamically set its label's back color to a specific color.  this is a
>visual cue that "this combo has the dbl-click behavior activated"
>
>What kinds of things do you have your controls do?
>
>John W. Colby
>www.ColbyConsulting.com
>
>
>--
>_______________________________________________
>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

_________________________________________________________________
Free yourself from those irritating pop-up ads with MSn Premium. Get 2months 
FREE*  
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines




More information about the AccessD mailing list