Dan Waters
dwaters at usinternet.com
Fri Sep 3 15:00:00 CDT 2004
Hello Karen,
I've only done this once with custom menus, but I did use an argument in the
Function. For example,
OnAction is =StatusChange("Green")
There are three items on the menu, Red, Yellow, and Green. They each call
the same Function, but the action is dictated by the argument.
In the Function, set up a Select Case scenario, and you've gone from three
functions to one.
HTH!
Dan Waters
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Nicholson, Karen
Sent: Friday, September 03, 2004 2:16 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] VB Menus - Creating Function for Actions?
I am coding my custom menus for many forms. From what I have read, it
seems that in order to process an .OnAction, one needs to create a
function that can be reference inside of, for instance:
.Caption = "Tracking Sheet - Approval Applications"
.OnAction = "fnOpenTrackingSystemCL"
Do I really need to create functions to execute something as simple as:
DoCmd.OpenForm "frmTrackingSystemCL", acNormal
DoCmd.Maximize
(which is in the function fnOpenTrackingSystemCL)
Show below is my code for the menu item; there are a few modules
associated with this code to make it work, but this is the bulk of it:
Sub CreateNewMenuB()
Dim strMenuNameB As String
Dim cmdNewMenuB As CommandBar
Dim cctlFormMenuB As CommandBarControl
Dim cctlExitMenuB As CommandBarControl
strMenuNameB = "ClosedProjectsMenu"
'If strMenuName exists then deleted it. Commandbars have unique
names.
'See global section for fIsCreated
If fIsCreated(strMenuNameB) Then
Application.CommandBars(strMenuNameB).Delete
End If
'Create a new Commandbar as MenuType
Set cmdNewMenuB = Application.CommandBars.Add(strMenuNameB,
msoBarTop, True, False)
With cmdNewMenuB
'Set commandbar protection to no protection so users can change
it
.Protection = msoBarNoProtection
'Show new menu
.Visible = True
End With
'Creating Form menu
Set cctlFormMenuB = cmdNewMenuB.Controls.Add(msoControlPopup)
cctlFormMenuB.Caption = "&File"
'Creating Exit menu under File
Set cctlExitMenuB = cctlFormMenuB.Controls.Add(msoControlButton)
With cctlExitMenuB
.Caption = "R&eturn"
.OnAction = "fnQuitApp"
.Caption = "Tracking Sheet - Approval Applications"
.OnAction = "fnOpenTrackingSystemCL"
End With
End Sub
Karen Nicholson
National Laboratory
Xerox Global Services
--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com