473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Mouse and ShortCut Menu Bar to execute my code

Hi

I am using the Shortcut Menu Bar property of a control to specify a
Custom popupmenu that displays when the right-click of the mouse is
used.

Can I place some kind of command in this Custom Right-Click Mouse
Menu, that can be selected by the user, and executes a procedure
containing my code???

ThankYou
Greg

Feb 15 '07 #1
2 4700
I would say that 90% of my custom menu bars call, and run my VBA code.

All you need to do is make the code (a function) public, and then simply
place the function name in the buttons on-action event code.

Further, likely often you will have specific code to a particular form, and
once again, you simply declare those functions (in that form) as public.

The syntax to call the code then is:

=YourFunctionName()

You place the above in the on-action setting of the menu.

Often, (if not most of the time), you code you call will need to pick up
some information about he current screen etc. So, my code most of the time
starts out, and grabs the current screen name. I use:

Public Function AskInvoicePrint()

Dim tblgroupid As Long
Dim frmActive As Form

Set frmActive = Screen.ActiveForm

tblgroupid = frmActive.frmMainClientB.Form!ID

If frmActive.InvoiceNumber = 0 Then
frmActive.InvoiceNumber = nextinvoice
frmActive.Refresh
End If

DoCmd.OpenForm "guiInvoicePrint", , , "id = " & tblgroupid

End Function

The above is code that the invoice print button runs. note how I right away
pick up the active form. After that, I can easily ref the forms object as if
the code was running much like the code would if put behind a button on the
form. In the above example, I also check if a invoice number has been
generated before printing. And, the Refresh forces a disk write if in fact I
do change the invoice number. And, in addition the above clip also passes
the currently selected sub-form item that the invoice print form needs.

Also, if the code you write is for the particular form, then as mentioned,
you can simply place the code into the forms module code. There is no need
to pick up the active screen...and you can use me. as you
always used.

If you want to see some sample menu bars, and why I use them, you can read
the following:

http://www.members.shaw.ca/AlbertKal...erFriendly.htm
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com


Feb 15 '07 #2
Great advice Albert!
Thanks for going the extra yard, you saved us future questions.

Greg

Feb 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Lex | last post by:
I am writing a C# app that has a Menu. Some of the menu items will have short cuts that do not exist in the Shortcut enum. I would like the custom shortcuts to appear on the menu but as far as I...
3
by: Terry Bell | last post by:
I have some code that adds entries to the "Module Compiled" popup menu. Works fine in A97. You can open a module, right click, and the new entries are there for you to click. I converted it to...
4
by: Salad | last post by:
A97. If you set a forms properties to ShortcutMenu = No, the entire form is disabled from displaying a shortcut menu. If you set the property to Yes, all controls have a shortcut menu. I have...
2
by: JMCN | last post by:
hi i'm having a problem with the customize a shortcut menu. i read the ms office assistance: customize a shortcut menu/delete a command or add to a shortcut menu and followed the simple...
5
by: Steven | last post by:
I have some text boxes on a form in MS Access 2000. When I right click in them I don't get any shortcut menu at all. I want the normal cut, copy, and past menu to come up. In the "Startup", I...
0
by: cefrancke | last post by:
I recently discovered, that if you set the startup options for "security", you will have alot of work do to get Access back to "normal". If you disable the built-in menus/toolbars you'll have to...
0
by: Marcel | last post by:
Hi, the application I am writing has a MainMenu and a DataGrid (UltraGrid). Now I have to edit the text of each cell in this grid. So far so good. All works fine in editmode but if I press a...
4
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create...
2
by: Jorgen Bodde | last post by:
Hi all, This is slightly OT but it drives me nuts. Whenever I create a shortcut in the start menu (in Windows) of a python script, it will only execute it when the path where the script resides...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.