PDA

View Full Version : capturing and passing a right-click



eed
09-10-2004, 08:26 AM
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.

eed
09-10-2004, 11:33 AM
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!