'----- start of code -----
Function ListHotKeys( _
            FormNameOrObject As Variant, _
            Optional ByVal Depth As Integer = 1) _
        As Integer

    ' Scan a form and list all hotkeys, including those on subforms.
    ' The form to be scanned may be passed by name -- that is, the
    ' name of the form may be passed as a string -- or by reference --
    ' that is, an object reference to the (open) form may be passed.
    ' If the name is passed, then if the form is not already open
    ' (in any view), the form will be opened in design view, scanned,
    ' and closed.
    '
    ' Output is written to the Immediate Window.
    '
    ' Arguments:
    '   FormNameOrObject -
    '       either a string containing the name of the
    '       form or an object reference to the opened form
    '   Depth -
    '       an optional argument used to assist in nesting
    '       the output of this function when it calls itself
    '       recursively to scan subforms.  This argument should
    '       not normally be called by the user.
    '
    ' Returns:
    '   The total count of hotkeys found.
    '
    ' Written by: Dirk Goldgar, 15 April 2009
    ' Copyright © 2009, Dirk Goldgar
    ' Permission is granted to use and adapt this code in 
    '     your applications, provided the attribution and
    '     copyright notice remain unchanged.

    Dim frm As Form
    Dim ctl As Access.Control
    Dim strCaption As String
    Dim strTargetControl As String
    Dim intPos As Integer
    Dim intNFound As Integer
    Dim blnCloseIt As Boolean

    If VarType(FormNameOrObject) = vbObject Then
        Set frm = FormNameOrObject
    Else
        If Not CurrentProject.AllForms(FormNameOrObject).IsLoaded Then
            DoCmd.OpenForm FormNameOrObject, acDesign
            blnCloseIt = True
        End If
        Set frm = Forms(FormNameOrObject)
    End If

    Debug.Print Tab(Depth); "Searching "; frm.Name; " for hotkeys ..."

    ' Search all controls on the current form, ignoring
    ' controls on subforms.
    For Each ctl In frm.Controls
        If ctl.ControlType = acLabel _
        Or ctl.ControlType = acCommandButton _
        Or ctl.ControlType = acPage _
        Then
            strCaption = Replace(ctl.Caption, "&&", vbNullString)
            intPos = InStr(strCaption, "&")
            If intPos > 0 Then
                strTargetControl = ctl.Name
                If ctl.ControlType = acLabel Then
                    If Not ctl.Parent Is frm Then
                        strTargetControl = ctl.Parent.Name
                    End If
                End If
                Debug.Print Tab(Depth + 1); _
                            "HotKey " & Mid$(strCaption, intPos + 1, 1); _
                            " triggers " & strTargetControl
                intNFound = intNFound + 1
            End If
        End If
    Next ctl

    ' Now search the controls on any subforms.
    For Each ctl In frm.Controls
        If ctl.ControlType = acSubform Then
            intNFound = intNFound + ListHotKeys(ctl.Form, Depth + 1)
        End If
    Next ctl

    Debug.Print Tab(Depth); _
                "Search of " & frm.Name & " is complete. "; _
                intNFound; "hotkeys found."

    Set frm = Nothing

    If blnCloseIt Then
        DoCmd.Close acForm, FormNameOrObject, acSaveNo
    End If

    ListHotKeys = intNFound

End Function
'----- end of code -----