473,569 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basing a menu item on a procedure instead of a function?

Back in the old days before I started learning about menubars (the day
before yesterday,) I based all my operations on command buttons on the
forms. Now the forms are all cluttered up with buttons so I'm beginning to
clean it up using menubars.

So far, I haven't used ANY macros. But some some websites, as well as my
book, seems to indicate that it is necessary to base the menubar on a macro
with each menu's first instruction being AddMenu.

I have made three menus without any macros that seem to work fine (until
now.) Some of my operations don't use forms, but use input boxes and DAO
queries. These operations were stuck in the code behind the forms. I have
a module in the Modules section called, "basMenuStu ff," where I'm putting,
of all things, menu stuff. In there I made a subroutine called "NewGroup."
All this does is gets a new group name and group weight from two different
functions, then get a course code from an open form. From these three
pieces of data, it does an INSERT INTO query. That's it. But I got the
following error in a MsgBox:

----------------------------------------------
The object doesn't contain the Automation object "NewGroup."

You tried to run a Visual Basic procedure to set a property or method for an
object.
However, the component doesn't make the property or method available for
Automation operations.

Check the compenent's documentation for information on the properties and
methods it makes available for Automation operations.
|OK|
----------------------------------------------

Is it possible that a menu item cannot be based on a subroutine but must be
based on either in a macro, form, or function?
Nov 13 '05 #1
3 2118
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The easiest way is to set the menu bar item to call a macro. The macro
will be a RunCode macro that calls a VBA function.

You can, also, set the menu bar item's "OnAction" event to a VBA
function, but you have to set up the call programmaticall y. You'd use
the CommandBar objects & related methods, properties.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQYFFUoechKq OuFEgEQJkhwCg/nm3HTt93ZAdp4eD +78rGkbOj5oAnRj C
1EDlIiIV/PTO4G6bfNV8QSVf
=OXzi
-----END PGP SIGNATURE-----
Richard Hollenbeck wrote:
Back in the old days before I started learning about menubars (the day
before yesterday,) I based all my operations on command buttons on the
forms. Now the forms are all cluttered up with buttons so I'm beginning to
clean it up using menubars.

So far, I haven't used ANY macros. But some some websites, as well as my
book, seems to indicate that it is necessary to base the menubar on a macro
with each menu's first instruction being AddMenu.

I have made three menus without any macros that seem to work fine (until
now.) Some of my operations don't use forms, but use input boxes and DAO
queries. These operations were stuck in the code behind the forms. I have
a module in the Modules section called, "basMenuStu ff," where I'm putting,
of all things, menu stuff. In there I made a subroutine called "NewGroup."
All this does is gets a new group name and group weight from two different
functions, then get a course code from an open form. From these three
pieces of data, it does an INSERT INTO query. That's it. But I got the
following error in a MsgBox:

----------------------------------------------
The object doesn't contain the Automation object "NewGroup."

You tried to run a Visual Basic procedure to set a property or method for an
object.
However, the component doesn't make the property or method available for
Automation operations.

Check the compenent's documentation for information on the properties and
methods it makes available for Automation operations.
|OK|
----------------------------------------------

Is it possible that a menu item cannot be based on a subroutine but must be
based on either in a macro, form, or function?


Nov 13 '05 #2
"Richard Hollenbeck" <ri************ ****@verizon.ne t> wrote in message
news:iKagd.1403 6$5O4.2722@trnd dc07...
Back in the old days before I started learning about menubars (the day
before yesterday,) I based all my operations on command buttons on the
forms. Now the forms are all cluttered up with buttons so I'm beginning
to
clean it up using menubars.
Great stuff. I also find that menus can significantly clean up those forms.

So far, I haven't used ANY macros. But some some websites, as well as my
book, seems to indicate that it is necessary to base the menubar on a
macro
with each menu's first instruction being AddMenu.


No, not all. As a general rule, I simply have all my menus call custom code.
That code can be in the forms module, or a general module.

In most cases, if the menu bar code is for the current form..then it makes
sense that the code belongs in the forms module..and not some other module.

Here is a few other points:

You do in fact have to use a function name..and you can't use a sub-name. If
you already got some extensive sub code written, you then just create a
function that calls the code.

The functions in the form have to be public. For example, MOST of my forms
have some custom delete code, and I ALWAYS call it

Public Function MyDelete
The advance of ALWAYS using the same function name should not be missed. If
you have a custom menu bar, then to call the forms code you put the function
name in the menu "on action" (I create all my menus via drag and drop with
the mouse by the way!).

So, to run the MyDelete function, you just type in the following into the
menus "on action" property setting:

=MyDelete()

The above goes in the on-action. What is very cool here is that this means
that ONE menu bar can apply to several forms. Which ever form has the focus
will have its public function called MyDelete() run. And, if the form does
NOT have a public function, then a function of the above name in a standard
module is tried to run. So, for example, you could write a common delete
function that applies to ALL forms,a and place the code in a standard
module. However, lets assume you have one form that needs special
treatment...you just then put a public function in the forms module of the
same name..and that one gets run!

Further, a LOT of my menu code is in standard modules, and some is in forms
module. If the code goes into a forms module, then you code can use things
like:

me.Refresh

or me.InvoiceNumbe r

However, for code in a general module..you can't use "me", so you what you
do is simply pick up the currently active form.

So, for "general" code, my code almost always grabs the active form...here
is a example for a invoice print option:

Dim tblgroupid As Long
Dim frmActive As Form

Set frmActive = Screen.ActiveFo rm

tblgroupid = frmActive.frmMa inClientB.Form! ID

If frmActive.Invoi ceNumber = 0 Then
frmActive.Invoi ceNumber = nextinvoice
frmActive.Refre sh
End If

DoCmd.OpenForm "guiInvoicePrin t", , , "id = " & tblgroupid
So, you can see that the trick here is to "pick up" the currently active
screen, and make a form ref that you can use. As mentioned, if you place
your menu bar code in the actual forms module..then you can use "me".

Here is some other ideas and screen shots of menu bars I made in ms-access
(all were created via drag and drop).

http://www.attcanada.net/~kallal.msn...erFriendly.htm
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #3
Thank you. Great reply!
Rich

"Albert D. Kallal" <Pl************ *******@msn.com > wrote in message
news:k8mgd.4849 2$%k.19372@pd7t w2no...
"Richard Hollenbeck" <ri************ ****@verizon.ne t> wrote in message
news:iKagd.1403 6$5O4.2722@trnd dc07...
Back in the old days before I started learning about menubars (the day
before yesterday,) I based all my operations on command buttons on the
forms. Now the forms are all cluttered up with buttons so I'm beginning
to
clean it up using menubars.
Great stuff. I also find that menus can significantly clean up those

forms.

So far, I haven't used ANY macros. But some some websites, as well as my book, seems to indicate that it is necessary to base the menubar on a
macro
with each menu's first instruction being AddMenu.
No, not all. As a general rule, I simply have all my menus call custom

code. That code can be in the forms module, or a general module.

In most cases, if the menu bar code is for the current form..then it makes
sense that the code belongs in the forms module..and not some other module.
Here is a few other points:

You do in fact have to use a function name..and you can't use a sub-name. If you already got some extensive sub code written, you then just create a
function that calls the code.

The functions in the form have to be public. For example, MOST of my forms
have some custom delete code, and I ALWAYS call it

Public Function MyDelete
The advance of ALWAYS using the same function name should not be missed. If you have a custom menu bar, then to call the forms code you put the function name in the menu "on action" (I create all my menus via drag and drop with
the mouse by the way!).

So, to run the MyDelete function, you just type in the following into the
menus "on action" property setting:

=MyDelete()

The above goes in the on-action. What is very cool here is that this means that ONE menu bar can apply to several forms. Which ever form has the focus will have its public function called MyDelete() run. And, if the form does
NOT have a public function, then a function of the above name in a standard module is tried to run. So, for example, you could write a common delete
function that applies to ALL forms,a and place the code in a standard
module. However, lets assume you have one form that needs special
treatment...you just then put a public function in the forms module of the
same name..and that one gets run!

Further, a LOT of my menu code is in standard modules, and some is in forms module. If the code goes into a forms module, then you code can use things
like:

me.Refresh

or me.InvoiceNumbe r

However, for code in a general module..you can't use "me", so you what you
do is simply pick up the currently active form.

So, for "general" code, my code almost always grabs the active form...here
is a example for a invoice print option:

Dim tblgroupid As Long
Dim frmActive As Form

Set frmActive = Screen.ActiveFo rm

tblgroupid = frmActive.frmMa inClientB.Form! ID

If frmActive.Invoi ceNumber = 0 Then
frmActive.Invoi ceNumber = nextinvoice
frmActive.Refre sh
End If

DoCmd.OpenForm "guiInvoicePrin t", , , "id = " & tblgroupid
So, you can see that the trick here is to "pick up" the currently active
screen, and make a form ref that you can use. As mentioned, if you place
your menu bar code in the actual forms module..then you can use "me".

Here is some other ideas and screen shots of menu bars I made in ms-access
(all were created via drag and drop).

http://www.attcanada.net/~kallal.msn...erFriendly.htm
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
http://www.attcanada.net/~kallal.msn

Nov 13 '05 #4

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

Similar topics

22
11064
by: Marek Mand | last post by:
How to create a functional *flexible* UL-menu list <div> <ul> <li><a href=""></li> <li><a href=""></li> <li><a href=""></li> </ul> </div> (working in IE, Mozilla1.6, Opera7 (or maybe even in Opera6))
10
2016
by: John Ortt | last post by:
Hi Everyone, I have created a Javascript menu for my site which uses frames. The first stage loads fine but I want two drill down menus ("About Me Menu" and "Projects Menu"). The pages load fine, but the images aren't displayed, instead the alt text is shown. The images come up after you "Mouse Over" them but not before......can anybody...
2
3868
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it...
3
2506
by: unurban | last post by:
I have a javascript menu based off of unordered lists that only shows the subnav links when you click on the main nav links. is there a way to keep any subnav items open after you click on a link and are transferred to a new page? Here is some of the code:
3
3037
by: scaredemz | last post by:
hi, so i'm creating a dynamic drop-down menu. the menu and the text show up fine in IE but only the drop-down shows in Firefox without the menu text. Below is the fxn code. help pls. function DropDownHelper(menuArray, top, left, height) { var currItem = new String(); var item; var idStr;
7
1798
by: joecap5 | last post by:
I have a main window from which I want to open a separate side menu window. I then want to create a list of items on that side menu by clicking on the item names in the main window. So far I am able to click on "Open Menu" and have the side menu open. I can then click on Items and have them added to the side menu using the innerHTML method or...
1
2505
by: Kayvine | last post by:
Hi guys, this is a question I have for an assignment, it is pretty long, but I am not asking for the code(well if someone wants to write I'll be really happy, lol), but I just want to know how to start it and what main topics in C I will need to cover in the assignment. Thanks a lot. CSC180 Assignment #3: Menu Madness Due Date: Thursday,...
0
2941
by: rahullko05 | last post by:
i have designed a menu list program in which i'm facing a problem where the last li item (white crappie) shifts down when i hover mouse pointer to just above li item (ozrack bazz) of white crappie instead (white crappie) li item should be to be sticked just below (ozrack bazz) li item without a down shift. i request u all to kindly sort the...
0
7701
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.