Heenan, Lambert
Lambert.Heenan at AIG.com
Tue Dec 11 13:39:31 CST 2007
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 '================================== ----- Original Message ----- From: Susan Harkins To: AccessD at databaseadvisors.com Sent: Friday, December 07, 2007 21:24 Subject: [AccessD] events question I don't know how to summarize this question, hence the bad subject. I apologize. I'm wondering if there's a way to consolidate similar event calls into one event. For instance, if you want to passto/call a function from every control's Mouse Over event, is there a simple way to do that with one call rather than dropping the call into every single control's appropriate event? I've run into this so many times and it just seems so inefficient. Susan H. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com