Susan Harkins
ssharkins at gmail.com
Tue Dec 11 13:10:20 CST 2007
I can't wait to try this A.D. Thanks! Susan H. > 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