none
Application.MenuBar RRS feed

  • Question

  • Has anyone tried this with any success?

    You have a A2003 DB with Menu Bar set (menu is basically created dynamically based on values in a table) then db properties set

    This works sweet in A2003 and sort of works in A2010. No matter what I do, it will not set Menu Bar property

     

    Lets say for example we create a custom menu using commandbars

     

        Dim x As CommandBar
        Dim y As CommandBarControl
    
        On Error Resume Next
        Set x = CommandBars("Main Menu")
        x.Delete
    
        Set x = CommandBars.Add("Main Menu", , True)
        Set y = x.Controls.Add
        With y
            .Caption = "&Option 1"
            .OnAction = "=Option1()"
        End With
        Set y = x.Controls.Add
        With y
            .Caption = "&Option 2"
            .OnAction = "=Option2()"
        End With

     


    Now in order to display main menu you have to uncheck allow full menus and built in toolbars. Code is already in place to hide the ribbons also.

    So have something like this now. changeDBProperty is essentially setting currentdb.properties. Im sure everyone has seen that code before. Code is just to hilite what is being done.

     

        changeDBProperty "AllowFullMenus", dbBoolean, False
        changeDBProperty "AllowBuiltinToolbars", dbBoolean, False
        changeDBProperty "MenuBar", dbText, "Main Menu"
    
        Application.MenuBar = "Main Menu"
        CommandBars("Menu Bar").Visible = True

     


    No matter what, Main Menu will not appear selected in Options nor does it show

     

    Anyone got any ideas?

    Forgot to mention, its the MDB being run in A2010 env.

    my ref: http://msdn.microsoft.com/en-us/library/ff194314.aspx

    Friday, September 2, 2011 4:57 PM

Answers

  • Hi Bruce

     

    I was initially told that main menu is set automatically so the main menu is set in Tools/Startup properties. So setup in vba and Main Menu should then appear in tools/startup so I was told.

    Now speaking with the person in charge of builds, he informs me they manually set the menu. A little annoyed to say the least as I was fed duff info. I should of tested myself more carefully instead of using what was passed to me. grrrr!

    Sorry about the time wasting here though I have learn't something new.

     

    The workarounds in the code for A2010 will have to suffice for the time being. What they are asking it seems is not possible. (hide the ribbon on startup so that the menu appears).

     

    • Proposed as answer by Bruce Song Monday, September 19, 2011 7:52 AM
    • Marked as answer by danishaniModerator Wednesday, February 1, 2012 6:20 AM
    Friday, September 16, 2011 10:27 PM

All replies

  • Hi Samsung Laptop,

    After reading your post, I am not very clear about your problem. And I can hardly reproduce the problem on my side. It will be nice if you can send a copy of your Access 2003 file and some screen shots to describe your problem and I will do the test on my side. You can send to me via this email v-bpeng@microsoft.com

    Besides, I have tried to add a CommandBar in Access 2003 according to your code, but it will not let me check to show, can you show the CommandBar in Access 2003? Here is my screen shot:

     

    I will do further research with your detailed information.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, September 6, 2011 4:00 AM
  • Hi Bruce, thanks for the reply. Sorry I didn't get chance to reply earlier. I will upload a sample tomorrow. Issue is with A2010, works sweet with A2003
    Wednesday, September 14, 2011 3:34 AM
  • Hi Bruce

     

    I was initially told that main menu is set automatically so the main menu is set in Tools/Startup properties. So setup in vba and Main Menu should then appear in tools/startup so I was told.

    Now speaking with the person in charge of builds, he informs me they manually set the menu. A little annoyed to say the least as I was fed duff info. I should of tested myself more carefully instead of using what was passed to me. grrrr!

    Sorry about the time wasting here though I have learn't something new.

     

    The workarounds in the code for A2010 will have to suffice for the time being. What they are asking it seems is not possible. (hide the ribbon on startup so that the menu appears).

     

    • Proposed as answer by Bruce Song Monday, September 19, 2011 7:52 AM
    • Marked as answer by danishaniModerator Wednesday, February 1, 2012 6:20 AM
    Friday, September 16, 2011 10:27 PM