[AccessD] events question

Bryan Carbonnell carbonnb at gmail.com
Fri Dec 7 10:09:19 CST 2007


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!"



More information about the AccessD mailing list