none
Ribbon - how to add button opening form, report, table or query. RRS feed

  • Question

  • In MS Access 2002 it is very easy - the name of table, query, form, report could be dragged with mouse from the list called "All Forms" etc. to the menu. But in Access 2016 and probably some earlier versions everything disappeared. How to create custom button in menu opening something using:
    1) mouse, not VBA, like in Access 2002.
    2) VBA or other advanced methods. I mean adding button which runs function opening a table for example, but not creating entire menu or button using VBA.
    Most important is #1, #2 is added only by the way.
    Thank you

    Edited much later:
    It seems, that changes made using
    File > Options > Customize Ribbon
    are applied for all databases. And I can't find simple way to open given form, report, table or query.

    But there is another way - create the table called USysRibbons (User System table) with two fields:
    - RibbonName (ShortText) and
    - RibbonXML (Memo / LongText)
    To make it visible after restarting the database the following setting should be applied:
    File > Options > Current Database > Navigation Options > Show System Objects

    An example content creating a button doing something, for example opening a table:

    Table USysRibbons:
    - RibbonName:
    Ribbon1
    - RibbonXML:

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
        <ribbon startFromScratch="false">
            <tabs>
                <tab id="Tab1" label="Tab1" visible="true">
    	     <group id="Group1" label="Group1">
                        <box id="Box1" boxStyle="horizontal">
                            <button id="Button1" imageMso="AccessFormDatasheet" label="Do something" onAction="=doSomething()"/>
                        </box>
    	    </group>
                </tab>
            </tabs>
        </ribbon>
    </customUI>
    Here:
    http://www.accessribbon.de
    is good webpage on ribbons XML. Sometimes such line is put above <tab id="...:

    <tab idMso="OneMoreID" visible="false" />

    What's that ?

    Public module:

    Public Function doSomething() As Boolean
    DoCmd.OpenTable "Table1"
    End Function


    To make it working a database must be restarted, the following setting applied:
    File > Options > Current Database > Ribbon Name > Ribbon1
    and the database restarted again.

    The ribbon can be much more customized, with images etc.
    How to do it without XML, VBA ?

    • Edited by _DK Saturday, April 23, 2016 7:50 PM
    Saturday, April 23, 2016 11:11 AM

Answers

  • Hi _DK,

    its look like you want to do it from user interface. not by codding using xml and VBA but here I want to tell you that you can customize the ribbon but you can customize only the things that are provided by the access inbuilt. if you want to customize to achieve the functionality like you mention above you must have to use XML and VBA. it is the easiest way to do it.

    Regards

    Deepak 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 25, 2016 1:08 AM
    Moderator

All replies

  • Hi _DK,

    its look like you want to do it from user interface. not by codding using xml and VBA but here I want to tell you that you can customize the ribbon but you can customize only the things that are provided by the access inbuilt. if you want to customize to achieve the functionality like you mention above you must have to use XML and VBA. it is the easiest way to do it.

    Regards

    Deepak 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 25, 2016 1:08 AM
    Moderator
  • XML is quite easy, I got accustomed to it yesterday and today. It looked difficult at first sight only.

    By the way - there is second way to call callbacks - Subs can be run too, not only functions, and they automatically receive some parameters from a control, like id. But this is offtopic.

    Monday, April 25, 2016 1:56 PM