Arthur Fuller
fuller.artful at gmail.com
Fri Dec 7 10:35:20 CST 2007
I think the previous explanation is appropriate. I use that approach often. For example, in a continuous form I define double-click as Sort, and another double-click as Sort Descending. I have a function just as outlined previously (in my case called SortByColumn()), and in the double-click property I just type this: <code> =SortByColumn([Form]) </code> In case anyone's interested, the code for said function is: <code> Public Function SortByColumn(f As Form) Dim ctlCurrentControl As Control Dim strControlName As String Set ctlCurrentControl = Screen.ActiveControl strControlName = ctlCurrentControl.Name Debug.Print strControlName Debug.Print f.OrderBy '08-Sep-01 'line changed to support subform invocation 'ActiveForm refers to the master form, not the subform ' If Screen.ActiveForm.OrderBy = vbNullString Then If f.OrderBy = vbNullString Then DoCmd.RunCommand acCmdSortAscending ' ElseIf Right(Screen.ActiveForm.OrderBy, 4) = "Desc" Then ElseIf Right(f.OrderBy, 4) = "Desc" Then DoCmd.RunCommand acCmdSortAscending Else DoCmd.RunCommand acCmdSortDescending End If Set ctlCurrentControl = Nothing 'DoCmd.RunCommand acCmdSortAscending 'or Descending End Function </code> hth, Arthur On 12/7/07, Susan Harkins <ssharkins at gmail.com> wrote: > > Did I botch another question? I know how to call a public function from > similar events. I want to eliminate all the calls from similar events. > > Instead of > > Object1_mouseover(.... > Call public function > End Sub > > Object2_mouseover(.... > Call public function > End Sub > > Object3_mouseover(.... > Call public function > End Sub > > and so on... just one call for ALL mouseover events. > > For any mouseover(... > Call public function > End Sub > > Does that even make sense? I don't think there's any way to do it, but I > thought I'd ask. > > Susan H. > > > On Dec 7, 2007 10:54 AM, Susan Harkins <ssharkins at gmail.com> wrote: > >> 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? > > > > Yes there is. > > > > In the Event that you want to control enter = > > YourFunctionName("Param1", "Param2", etc) > > > > And then create a public function > > > > Public Function YourFunctionName (Param1 as variant, param2 as string, > > etc) > > > > 'Code goes here > > > > End Function > > > > Here is an example from an App in use: > > > > I used the On Mouse Move event, so in the Mouse Move event in the > > Properties dialog I entered: > > > > =HandleButtonIndent("lblAdd") > > > > Then I have a public function: > > > > Function HandleButtonIndent(ControlName As String) > > > '-------------------------------------------------------------------------- > > '.Purpose : > > '.Author : Bryan Carbonnell > > '.Date : 2004-Mar-17 > > '.Called by : > > '.Calls : > > '.Inputs : > > '.Output : > > '.Revised : 2004-Mar-17 - Original > > > '-------------------------------------------------------------------------- > > > > Dim ctl As Control > > > > On Error GoTo HandleButtonIndent_Error > > > > For Each ctl In Me.Controls > > If ctl.Properties("ControlType") = 100 Then > > If ctl.SpecialEffect <> 0 Then > > ctl.SpecialEffect = 0 > > End If > > End If > > Next > > > > If ControlName <> "" Then > > Me.Controls(ControlName).SpecialEffect = 2 > > End If > > > > Exit_HandleButtonIndent: > > > > On Error GoTo 0 > > Exit Function > > > > 'Error Handler > > HandleButtonIndent_Error: > > > > With ErrorLog > > 'Log Error > > .LogError "Form_frmIncidentLog", "HandleButtonIndent", _ > > Err.Number, Err.Description, "Custom Error Message" > > 'Display Error Message > > MsgBox "Error " & .ErrorNumber & " (" & .ErrorDescription & _ > > ") in procedure " & .ProcedureName & " of " & .ModuleName > > End With > > > > 'Exit the procedure properly > > Resume Exit_HandleButtonIndent > > 'For Debugging > > Resume > > > > End Function > > > > -- > > Bryan Carbonnell - carbonnb at gmail.com > > Life's journey is not to arrive at the grave safely in a well > > preserved body, but rather to skid in sideways, totally worn out, > > shouting "What a great ride!" > > -- > > 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 >