473,386 Members | 1,706 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,386 software developers and data experts.

Reference Menu Captions in VB

I want to use a custom menu as an input device for a form. I can
assign a macro that calls a function for each submenu ie:

Public Function Fall_to_Lower_Level_Unspecified() As String
Forms!frm_Data!Hazards = "Fall to lower level, unspecified"
End Function

However, each level of my menu has a unique caption which I could use
as the input string for my form. Does anyone know how to reference a
specific caption for a submenu of a custom menu? This menu will
contain over 100 choices.
Nov 13 '05 #1
2 1712
Would it not be better to have each menu item call code, and dump the
macros? (this is not a anti-macro post..but you don't need them in this
case).

Any pubic function name can be run from a menu item direct if you place the
function name right in the menus on-action property.

So:

=FallLower("1")
Public Function FallLower(strP as string)

'value passed from menu is strP

end function.

As a general rule, all of my menu code calls code direct as above. Further,
any code that works on a screen can simply pick up the current active forms,
and work from that (this way, you can move button code from the form to your
menu bars). For example:

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()

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.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 #2

Thanks. I have a menu with 220 sub-elements. It took 2 days to apply the
code. There must be a way of referencing the caption associated with the
sub-elements. Then pass that value thru a single function to the active
form.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

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

Similar topics

5
by: Robert J. O'Hara | last post by:
For some time I've struggled with the problem of displaying simple captioned figures on webpages in a way that is robust and scalable. I tend to make "boring" (um, I mean "conservatively elegant")...
0
by: public heath vb developer | last post by:
We have a solution with 29 projects including a main menu and 28 dlls. One of the projects (Project B) was created by copying an existing project (Project A), making changes including the assembly...
4
by: CB US 77 | last post by:
I use a piece of javascript to create a photo gallery slideshow. The slideshow part works great, but I would like to add captions to each picture. If you want to see the html, send me an email to...
3
by: David | last post by:
Hi, I need a button shown for each record (cont. form) with specific captions on each. I have a notes form for each record. When a user presses the button they can read the notes. I want to...
1
by: mmitchell | last post by:
Using vb.net 2005 I added a MainMenu item to a form which worked just fine until I also added a contextmenutab. After adding the contextmenutab the mainMenu captions disapeared from the form at...
5
by: | last post by:
I nearly always use HTML in notepad, but I'm looking for a solution to what I think will be a common problem. I want to add a caption to photos that have been scanned in to make a single picture....
2
by: harambeegirl | last post by:
I have read the CSS tutorial at W3Schools.com. It states that the caption-side property is not supported in IE6. If I want to add captions to my images, what else can I do?
7
by: Johnny | last post by:
In MSIE table captions are displayed at the same size as content. But in Firefox the text displays at browser default, It also exceeds the width of the table and the excess is hidden if the table...
0
by: Alan Mailer | last post by:
When adding a new Menu to a VB6 application, a developer had the option of designating the Menu as a 'WindowList' Menu. By choosing this option at Design time, it enabled this particular menu at...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.