Results 1 to 4 of 4
  1. #1
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Creating a Menu (2003/SP2)

    Can anybody tell me how to create a custom Menu in Access? I have created them in Excel but the code is in the worksheet.

    Where do I program it in Access?

    I am not talking about a Switchboard -- I need pull-down menu items.
    Alan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating a Menu (2003/SP2)

    In Excel, custom toolbars and menus are shared among all workbooks, so it's a good idea to create a custom toolbar or menu when the workbook is opened, and to delete it when the workbook is closed.

    In Access, custom toolbars and menus are stored in the database, and they will only be active when the database is open. So in general, you can design the toolbars and menus interactively, in Tools | Customize...

    You can specify that a custom toolbar and/or menu will be used by a form or report in the Other section of the Properties window, by setting the (surprise) Toolbar and Menu Bar properties.

    If you have advanced needs, you can write the code to create the menu in a standard module, and run the code once. The toolbar or menu will be stored in the database.

  3. #3
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Creating a Menu (2003/SP2)

    I got it! I will use an AutoExec to start it when the database opens.
    <pre>Sub Toolbars_AddInInstall()
    Dim objCmdBrPp As CommandBarPopup
    Dim objCmdBtn As CommandBarButton
    Dim myCustom As CommandBarControl
    Dim MenuItem As CommandBarControl
    Dim SubMenuItem As CommandBarButton
    Dim cbcMenuBar As CommandBar
    Dim iHelpIndex As Integer

    Set cbcMenuBar = Application.CommandBars("Menu Bar")
    iHelpIndex = cbcMenuBar.Controls("Help").Index

    Set myCustom = cbcMenuBar.Controls. _
    Add(Type:=msoControlPopup, Before:=iHelpIndex, Temporary:=True)
    <font color=red> 'Temporary causes it to disappear when app is closed</font color=red>
    With myCustom
    .Caption = "&Meter Dept"
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Reports and &Append"
    .OnAction = "GetWorkForm"
    .FaceId = 99
    .BeginGroup = True
    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "&Foreman Form"
    .OnAction = "OpenForemanCheck"
    .FaceId = 30

    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Service &Truck"
    .OnAction = "TruckUtils"
    .FaceId = 498
    'Is there a face like Airplane?
    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Sales &Report"
    .OnAction = "SalesReport"
    .FaceId = 107
    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "&Close Database"
    .OnAction = "CloseAndExit"
    .FaceId = 9527
    End With
    End With
    End Sub

    </pre>

    Alan

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating a Menu (2003/SP2)

    That should work, but why make the items temporary? They don't look dynamic, so creating them once (and not temporary), should be sufficient...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •