Right Click Event

gray

Registered User.
Local time
Today, 05:34
Joined
Mar 19, 2007
Messages
578
Hi All

Access2002/2007
WinXpPro

Does anyone know how I detect a right click on an Access Form? I'm trying to find out which context menu option the user has selected.

I believe there's a BeforeRightClick in Excel but can't see an equivalent in Access?

Thanks
 
You can use the MouseDown event to detect left or right click
 
Hi

I've added a msgbox to the Mousedown event and I have KeyPreview set to yes but the Mousedown event does not fire? Any idea why?
 
Code:
Private Sub Command0_MouseDown([B]Button [/B]As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 2 then Right Click was clicked

End Sub
 
Hi

Thanks for the tip David... unfortunately my mousedown event does not fire at all... I thought with KeyPreview=Yes that it would?
 
Are you doing it on a textbox or a command button?
 
Hi

I'm right_clicking a textbox...
 
Well I just tried doing what you are asking and it worked fine. What code do you have on your MouseDown event of the textbox?

I had

MsgBox Button

Left click = 1
Right click = 2
 
Arrghh .. sorry David, I should have read your post more carefully... you are using the control mousedown... I'm using the form mousedown... I've a large-ish number of controls on my form so I was hoing to trap it using the Form mousedown to save coding on all the boxes....
 
The form MouseDown if for the "white space" on the form you will have to code the controls individually
 
Okay I see.... thanks....

And do you know how I detect the selected menu option in the mousedown event... I've been reading up on meniu handlers but I can't say I really understand them yet...

thanks
 
The one I'm particularly interested in at present is the filter/sort context menu... as attached... trying to trap the 'clear filter........' option
 

Attachments

  • Right_Click_Menu.JPG
    Right_Click_Menu.JPG
    46.7 KB · Views: 272
I don;t know if you can trap custom menu items. You may need to create your own and program them acordingly.
 
Ahh... I had a horrible feeling that might be the case...

I might leave this open cos' our U.S. cousins are just about coming on-line... maybe one of them has cheated Access menus before...

Thanks for your assistance..
 

Users who are viewing this thread

Back
Top Bottom