[AccessD] VB Menus - Creating Function for Actions?

Mike & Doris Manning mikedorism at adelphia.net
Fri Sep 3 15:07:53 CDT 2004


I'm afraid so.

Doris Manning
Database Administrator
Hargrove Inc.
www.hargroveinc.com


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Nicholson, Karen
Sent: Friday, September 03, 2004 3: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




More information about the AccessD mailing list