Consulting

Results 1 to 2 of 2

Thread: capturing and passing a right-click

  1. #1
    VBAX Contributor
    Joined
    Jun 2004
    Location
    Texas
    Posts
    139
    Location

    SOLVED: capturing and passing a right-click

    Hi, all,

    I've got this generic function that I'm calling on the MouseDown events of a whole bunch of buttons:
    Public Function OpenHelp(strTopic As String)
    Dim frm As Form, strCriteria As String
    strCriteria = "[CaseKey] = '" & strTopic & "'"
    DoCmd.OpenForm "FmGlobalHelpWindow", , , strCriteria
    End Function

    Then each button has code like this:
    Private Sub Command44_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = acRightButton Then OpenHelp ("AdminEVbtnA1")
    End Sub

    But it is taking a lot of code to capture the right-click in one place and then pass the string to the opening procedure. If the first, generic function could interpret the mouse button that was pressed, I think it would simplify things. So, instead of using an Event Procedure, the button's OnMouse property could be something like:
    =OpenHelp(<<Button?>>, "AdminEVbtnA1")

    And the OpenHelp function could be something like:
    Public Function OpenHelp(btn as integer, strTopic As String)
    Dim frm As Form, strCriteria As String
    If btn = acRightButton Then
    strCriteria = "[CaseKey] = '" & strTopic & "'"
    DoCmd.OpenForm "FmGlobalHelpWindow", , , strCriteria
    End If
    End Function

    What I am not sure of is how to pass the button's "click" value so that the OpenHelp function can then interpret its value as Left, Right, or Middle. Any ideas?

    If I should give up on the right-click idea, is there another generic way to open a form filtered to the one record that corresponds to a specific control? I like the way some applications let you click on the toolbar to get a "?" cursor, which you can then click on to see the object's definition... But I'm unsure how to implement such a thing...

    Thanks in advance for any and all thoughts.
    With program specs this fickle, you've just got to believe in Discord.

  2. #2
    VBAX Contributor
    Joined
    Jun 2004
    Location
    Texas
    Posts
    139
    Location

    Talking

    Okay, I've found a better way to solve this problem. I've created a custom shortcut menu with just one line ("Get Custom Help") whose action is set to:
    =OpenHelp(Screen.ActiveControl.Tag)

    The tag contains the string that needs to be passed to the OpenHelp function. So instead of a billion lines of code capturing right-clicks, I just need to set the shortcut menus on the affected controls to my custom menu.

    So this is solved! Thanks anyway!
    With program specs this fickle, you've just got to believe in Discord.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •