[AccessD] events question

jwcolby jwcolby at colbyconsulting.com
Tue Dec 11 13:49:19 CST 2007


An additional problem is that everyone wants to use the tag property for
their own purpose and so it is useless without a parser and custom syntax. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: Tuesday, December 11, 2007 2:40 PM
To: 'Access Developers discussion and problem solving'
Cc: 'A.D.Tejpal'
Subject: Re: [AccessD] events question

Looks nice. But there's a problem. Access controls do not have a MouseOut
event, so while the code in Fn_Mmove will change the controls' colors,
nothing changes them back. So you need a MouseMove event for the form
sections as well. Said section events will look for any controls that are
"Red" and change them back. The trouble with *that* is if your controls are
close together, or there are lots of them, the containing section's mouse
over event may not fire as the mouse is not "seen" for long enough.

My 2 cents.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D.Tejpal
Sent: Tuesday, December 11, 2007 12:54 PM
To: Access Developers discussion and problem solving
Cc: A.D.Tejpal
Subject: Re: [AccessD] events question


Using common function for MouseMove over multiple controls
==========================================

    1 - MouseMove over a given control does not necessarily imply that the
control in question is the active control. This rules out the use of an
omnibus function based upon ActiveControl. Instead, it becomes necessary
that even if a common function of generic nature is used for all controls,
name of each individual control making the call has to be passed as an
argument.

    2 - Evidently, conventional approach in calling such a function from
MouseMove events of multiple controls involves tedious work by the
developer. Repetitive entries of function name (with control name as
argument) are needed either in VBA code in MouseMove event for each of the
controls in question, or directly as similar entries against OnMouseMove
property on Event tab in properties dialog box of each such control.

    3 - An interesting alternative that makes the whole process remarkably
simpler, is suggested below:

    3.1 - With form in design view, select all controls required to make use
of the common function. Set the tag property of these controls to "MM"
(simply enter MM without any enclosing quotes).  Save.

    3.2 - Go to VBA window and place the sample code as given below, in
form's module. Save and compile. Come out of VBA window, save and close the
form.

    3.3 - As the form loads, OnMouseMove event property of all the above
controls will get set to function Fn_MMove(), correctly passing the name of
control as argument in each case. 

    3.4 - As per the common function Fn_MMove() given below, back color of
all the above text boxes (having "MM" as the tag property) will change to
red on mouse move.

A.D.Tejpal
------------

Sample code in form's module '==================================
Private Sub Form_Load()
    On Error Resume Next
    Dim ct As Control
    
    For Each ct In Me.Controls
        If ct.Tag = "MM" Then
            ct.OnMouseMove = _
                "=Fn_MMove('" & ct.Name & "')"
        End If
    Next
    On Error GoTo 0
End Sub
'--------------------------------------------------

Private Function Fn_MMove(StrTxtBoxName As String)
    Me(StrTxtBoxName).BackColor = vbRed
End Function
'==================================




More information about the AccessD mailing list