[AccessD] VB Menus - Creating Function for Actions?

Nicholson, Karen cyx5 at cdc.gov
Fri Sep 3 14:15:48 CDT 2004


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





More information about the AccessD mailing list