Solved

new to Access 2010 - hiding ribbon

Posted on 2013-05-30
25
1,020 Views
Last Modified: 2013-06-03
Hi EE,

If one uses the UsysRibbons table approach to create a ribbon that shows very little
to essentially hide the ribbon and calls it HideTheRibbon, and then specifies this
ribbon name under File/Options/CurrentDatabase, then when click on accdb, the ribbon
is hidden

what happens if you want to go back to development mode and use Access default ribbons.

how do you toggle between show/hide ribbon

a) do you press SHIFT key while click on accdb to break into db for development

b) for some reason the show/hide toolbar "ribbon" vba is not working for me

below is an uploaded test mdb. Nick and EE expert helped me with it yesterday.

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_28140895.html

c) p.s.  i learned here how to manually turnoff the tab in the ribbon called Adobe:

   http://social.msdn.microsoft.com/Forums/en-US/accessdev/thread/1d79779c-a229-4c50-81dd-0f27f97a828c/

   so if you are expecting to see the Adobe tab on your machine, it is missing bec i turned
  off the add in.

tx in advance for your help, sandra
Nick-EE.accdb
0
Comment
Question by:mytfein
  • 16
  • 8
25 Comments
 
LVL 20

Assisted Solution

by:GrahamMandeno
GrahamMandeno earned 200 total points
Comment Utility
Hi Sandra

a)  Yes, you are correct - if you hold the Shift key when you open a database, then ALL of the startup options are ignored, including the custom ribbon setting.  This feature can be "turned off" by creating a database property named "AllowBypassKey" and setting its value to False.

b)  DoCmd.ShowToolbar "Ribbon", acToolbarNo can be used at any time to hide the current ribbon, and DoCmd.ShowToolbar "Ribbon", acToolbarYes will show it again.
However, you should remember that the "current ribbon" changes when you open different objects - for example, if you hide the database ribbon and then open a form then the form ribbon will show.  To avoid this you can put code to hide the ribbon in each form's Form_Open event procedure.

Best wishes,
Graham Mandeno [Access MVP 1996-2013]
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 300 total points
Comment Utility
I think this is what you want.
I have added a second entry to USysRibbons that is a ribbon and BackStage that shows everything.
I have added the VBA reference to the Office 14.0 objects that the Ribbon code needs
I have extended your DevelopmentLibrary module to include the db property CustomRibbonID that toggles with all the rest of the test/ production properties between ID =1 (locked down ribbon entry) and ID = 2 (which is the new, unlocked entry)

Enjoy!

Nick67
Nick-EE.accdb
0
 

Author Comment

by:mytfein
Comment Utility
Hi Graham,
     tx so much for writing and tx for the info....


Hi Nick,
     1) tx so much for writing and the enhanced accdb.
 
     i appreciated so much how you understand that i want a toggle between
     prod(hide ribbon)   test(show ribbon for development),

     as my object is to convert mdbs to accdbs as easily for me as possible
     as i am more of a cut and paste vba user.....




     2) some questions, pls:

     a) am i supposed to turn off  file/options/client settings/uncheck show errors

               bec am getting errors when open the accdb

                   pls this screen shot:


s1
           when i check off the above, the errors go away

      b)  i see this public module... is it being called in the accdb
                 did a search, and do not seem to find a call to this sub....

s2
      c)   pls confirm that ribbon name is not being manually set under
file/options./currentdatabase, as  the ribbon field is empty in the screen shot below

[embed=file 657512


       d)  i see that you added in the deployment library to the toggle prod/test logic

prod:
      SetApplicationProperty "CustomRibbonId", dbInteger, 1
   
test:  
       SetApplicationProperty "CustomRibbonId", dbInteger, 2

End If


        does the 1 and 2 match up to the records in UsysRibbons Table
         Access "knows" to go to UsysRibbons table to the right row, to create
         a CustomRibbonId using the associated XML?

e)  XML:

     1) <ribbon startFromScratch="false">

      does this automatically load the a2010 default ribbon for development?

      2) i think i now understand why i got error msg above when clicked on accdb
          i compared the XML of ShowRibbon to my actual File tab

          and i do not have a share tab

           here is the xml screen shot:

           s4

           now here is the actual file tab, and there is no share area:

s5
3) what is the correct terminology for:
    file/home/create  etc..  to me they look like tabs

        however in the xml, the file tab is being modified using a keyword "ribbon" for
               backstage

        and under the file-backstage area:
                 the info/recent/new print use XML keywords that refer to themselves as tabs

4) if i press alt+p   to be in prod mode
    then exit accdb
    then click accdb

    unfortunately the ribbon still shows, pls see screen shot below

s6
5) tx very much Nick for this accdb and yesterday's version,
    my knowledge of ribbons and xml is slowly improving

tx, s
2013-05-31c-ribbon.bmp
0
 

Author Comment

by:mytfein
Comment Utility
for c above:


reshowing screen shot:  where ribbon area is blank, bec vba is setting ribbon, instead

 


it looks like i deleted question that i had of XML using the screen shot below:


1) <ribbon startFromScratch="false">

    does this load the default Access ribbons back?

2) the fact that we tinkered with backstage using ribbon #1,  means if we want
    to show the full backstage back, we have to write XML to do that

    if <ribbon startFromScratch="false">
       shows the default ribbon, why do we have to re-build the backstage to the
       way backstage normally looks like?

tx for your help, ss1for c above:


reshowing screen shot:  where ribbon area is blank, bec vba is setting ribbon, instead

 


it looks like i deleted question that i had of XML using the screen shot below:


1) <ribbon startFromScratch="false">

    does this load the default Access ribbons back?

2) the fact that we tinkered with backstage using ribbon #1,  means if we want
    to show the full backstage back, we have to write XML to do that

    if <ribbon startFromScratch="false">
       shows the default ribbon, why do we have to re-build the backstage to the
       way backstage normally looks like?

tx for your help, ss2for c above:


reshowing screen shot:  where ribbon area is blank, bec vba is setting ribbon, instead

 


it looks like i deleted question that i had of XML using the screen shot below:


1) <ribbon startFromScratch="false">

    does this load the default Access ribbons back?

2) the fact that we tinkered with backstage using ribbon #1,  means if we want
    to show the full backstage back, we have to write XML to do that

    if <ribbon startFromScratch="false">
       shows the default ribbon, why do we have to re-build the backstage to the
       way backstage normally looks like?

tx for your help, ss1for c above:


reshowing screen shot:  where ribbon area is blank, bec vba is setting ribbon, instead

 


it looks like i deleted question that i had of XML using the screen shot below:


1) <ribbon startFromScratch="false">

    does this load the default Access ribbons back?

2) the fact that we tinkered with backstage using ribbon #1,  means if we want
    to show the full backstage back, we have to write XML to do that

    if <ribbon startFromScratch="false">
       shows the default ribbon, why do we have to re-build the backstage to the
       way backstage normally looks like?

tx for your help, s
0
 

Author Comment

by:mytfein
Comment Utility
sorry, i editted the comment 3 times, and instead of updating
     in place, it added the comment as 3 sep. entries
0
 

Author Comment

by:mytfein
Comment Utility
hi,

maybe got an error when clicked accdb, bec the XML refers to a tab called share
and i do not see such an area in backstage view


s1
tx, s
0
 
LVL 26

Expert Comment

by:Nick67
Comment Utility

a) am i supposed to turn off  file/options/client settings/uncheck show errors
Short answer: Yes
The Ribbon is context sensitive.  When you start to muck with it MS figures that you'll create many entries in USysRibbons, ones that will be correct for all the different contexts and that you'll see to it that you seamlessly switch Ribbons in all contexts -- or you just turn off the error reporting :)


b)  i see this public module... is it being called in the accdb did a search, and do not seem to find a call to this sub....

It is actually called by the XML of the USysRibbons entries.


c)   pls confirm that ribbon name is not being manually set under
file/options./currentdatabase, as  the ribbon field is empty in the screen shot below

Correct.  That entry corresponds to the Database Property 'CustomRibbonID' and is manipulated programmatically by your DevelopmentLibrary code.  It must remain blank, or that code will not work correctly.


now here is the actual file tab, and there is no share area:

Then in the <BackStage></BackStage> bit of the XML I used in the USysRibbons entry of ShowTheRibbon, I not have found a complete example of a full BackStage on Google, that I copied and pasted there.  Does it have a TabShare entry?  If not, it will need one.  If it has one, is Visible = "true" ?


1) <ribbon startFromScratch="false">
    does this load the default Access ribbons back?

No, the only way you get the default MS Ribbon is if no USysRibbons entries are used at all.  On the other hand 'startfromScratch=false' tells the system that our customized Ribbon will be based on the default MS Ribbon as a start point.  When we do no other customization we end up with a custom Ribbon that is exactly like the default Ribbon--but it is still OUR custom Ribbon.


2) the fact that we tinkered with backstage using ribbon #1,  means if we want
    to show the full backstage back, we have to write XML to do that
Correct

    if <ribbon startFromScratch="false">
       shows the default ribbon, why do we have to re-build the backstage to the
       way backstage normally looks like?

Look carefully at the XML
The outermost tag is <customUI></customui>
Within that we can have three major tags -- only two have been discussed with you so far
<Ribbon></Ribbon>
<BackStage></BackStage>
The third is the quick access toolbar
<qat></qat>
They are independent of one another.
You could choose to ONLY modify the BackStage, if that suited your purposes.

Here, perhaps, is a more complete BackStage sample (tabShare?)  You want visible to = true in your ShowTheRibbon XML; here it is set to false.  Change accordingly.
  <backstage>
   <button idMso="FileSave" visible="false"/>
   <button idMso="SaveObjectAs" visible="false"/>
   <button idMso="FileSaveAsCurrentFileFormat" visible="false"/>
   <button idMso="FileOpen" visible="false"/>
   <button idMso="FileCloseDatabase" visible="false"/>
   <tab idMso ="TabInfo" visible="false"/>
   <tab idMso ="TabRecent" visible="false"/>
   <tab idMso ="TabNew" visible="false"/>
   <tab idMso ="TabPrint" visible="false"/>
   <tab idMso ="TabShare" visible="false"/>
   <tab idMso ="TabHelp" visible="false"/>
   <button idMso="ApplicationOptionsDialog" visible="false"/>
   <button idMso="FileExit" visible="false"/>
  </backstage>

Open in new window


We must rebuild the BackStage with many entries because MS did not see fit to make 'startfromscratch' applicable to BackStage.  It would be very nice to go
<BackStage startFromScratch="false"> </BackStage> but alas, that syntax is not supported.

Stupid omission by MS, but there you have it.

Nick67
0
 

Author Comment

by:mytfein
Comment Utility
Hi Everybody,

i'm back...

i would like to note that my other post is similar, it's just that i'm seeing diff. approaches
and am wanting one that works for me

a) hiding toolbar with DoCmd.ShowToolbar "Ribbon", acToolbarNo  did not work for
    me and did put this logic in Form open event

b) minimize the ribbon using vba code - you're right it's not hiding it

c) did some more research using google for: db application property customribbonid
that Nick pointed out, and found out a related piece of info that a form has
a ribbon property

http://www.utteraccess.com/forum/lofiversion/index.php/t1971027.html

so i went to the Form Open event and added this:

    Private Sub Form_Open(Cancel As Integer)

Dim strBackMode   As String
Dim strBackHour   As String
Dim blnBackGoodIO As Boolean

Call z932_WhichProcessMode(strBackMode, _
                           blnBackGoodIO)
                           
pg_strUserName = strGetUserName

DoCmd.Maximize


Me.lstSelect.SetFocus

If DevelopmentMode() = False Then  'prod mode
   Me.txtMode = "PRODUCTION Mode"

   Call DisplayNavPane(False)
   
   Me.RibbonName = "HideTheRibbon"

Else                                'test mode
   Me.txtMode = "TEST Mode"

   Call DisplayNavPane(True)

   Me.RibbonName = "ShowTheRibbon"
End If

End Sub


===
If you click on the accdb:
       you will see the form with ribbon hidden

     (btw, this works now bec i unchecked to be notified for add in errors
           i wish i could solve this error msg and put the check box back....)

===

so definitely having 2 ribbons
     1 for prod
     2 for test

and setting the ribbon name via the form's ribbon name property in the form's
open event   is the major part of solution

====

if the above is true, then am unsure if the database property for customribbonid
is working to point/display the ribbon associated with the number

====

below is a sample db,  tx, s
2013-05-31-Nick-EE.accdb
0
 

Author Comment

by:mytfein
Comment Utility
Hi Nick,

tx so much for great expanations!

went to USysRibbons table and looked at XML  and do not see

where this sub is called:

Public Sub OnMainLoad(ribbon As IRibbonUI)
 Set m_ribbon = ribbon
End Sub


here is the XML:

Id      RibbonName      RibbonXML
1      HideTheRibbon      "<customUI xmlns=""http://schemas.microsoft.com/office/2009/07/customui"" >
<ribbon startFromScratch=""true"">
</ribbon>
<backstage>
  <button idMso=""FileExit"" visible=""true""/>  <tab idMso=""TabPrint"" visible=""false""/>
</backstage>
</customUI>"
2      ShowTheRibbon      "<customUI xmlns=""http://schemas.microsoft.com/office/2009/07/customui"" >
<ribbon startFromScratch=""false"">
</ribbon>    <backstage>
        <button idMso=""FileSave"" visible=""true""/>
        <button idMso=""FileSaveAs"" visible=""true""/>
        <button idMso=""FileOpen"" visible=""true""/>
        <button idMso=""FileClose"" visible=""true""/>
        <button idMso=""ApplicationOptionsDialog"" visible=""true""/>
        <button idMso=""FileExit"" visible=""true""/>
        <tab idMso=""TabInfo"" visible=""true""/>
        <tab idMso=""TabRecent"" visible=""true""/>
        <tab idMso=""TabNew"" visible=""true""/>
        <tab idMso=""TabPrint"" visible=""true""/>
        <tab idMso=""TabShare"" visible=""true""/>
        <tab idMso=""TabHelp"" visible=""true""/>
        <tab idMso=""TabPublish"" visible=""true""/>
        <tab idMso=""TabSave"" visible=""true""/>
        <tab idMso=""TabOfficeStart"" visible=""true""/>
    </backstage>
>
</customUI>"

Can you pls advise, tx, s
0
 

Author Comment

by:mytfein
Comment Utility
Hi Nick,

Maybe i should set this CustomRibbonId property in the form's open event
as an experiment, just like i experimented there with the form's ribbon name.


well, i just tried it:
     and got the strangest error msg that is does not recognize the syntax
         and this syntax is being used fine in the deployment module....s1
0
 

Author Comment

by:mytfein
Comment Utility
Hi Nick,

just wanted to elaborate on the Development library code.

Many years ago, a colleague gave me this code, and i lost contact with him.

His approach is:
       on the main form of mdb system, to have 2 transparent buttons
        alt+t - executes code to set an application property of developmentMode to true
        alt+p- executes code to set an application property of developmentMode to false

the the form's open event tests the development code:

       if developmentMode() = true
            show a2003 menu bars
       else
           hide a2003 menu bars
       end if

so the area in the Deployment library that you created the new application property
called Custom Ribbon Id, only executes when user press alt+t  or alt+p from main
form. Every form that opens after that just tests the developmode() property for
true and false (including the main form) in form's open event to show/hide menubars
(or in this case ribbons)

tx, s
0
 

Author Comment

by:mytfein
Comment Utility
Hi Nick,

as you can tell, i am slowly reviewing your great explanations above.

about:  Tab Share

yes, in the ShowTheRibbon XML   tab share   ** is set to true **

however,

if i do not see on file back stage  an area called "share"

tx, s
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:mytfein
Comment Utility
s1
0
 
LVL 26

Expert Comment

by:Nick67
Comment Utility

     and got the strangest error msg that is does not recognize the syntax
         and this syntax is being used fine in the deployment module....

Remember that I said I added a reference to the MS Office Objects 14.0?
Open the sample
Open the code window
Tools|References
You should see that reference there.
You'll need that reference in any db where you are manipulating/loading the Ribbon via VBA
Missing references cause very odd errors.
The errors do not accord with the reference
When I break my reference to RemoteCE.tlb (what that is isn't important to you) suddenly VBA says it has no idea what CHR() is anymore.  Completely unrelated.


went to USysRibbons table and looked at XML  and do not see where this sub is called:

I may have removed it then.
Have a look at the sample from the first question I answered for you.
It is in play there, perhaps you may not need it.
Comment it out and see what happens


about:  Tab Share

Remember, things are context sensitive.  TabShare won't show if you've opened BackStage from an object or situation where sharing doesn't make any sense (like with no objects open, perhaps)
0
 
LVL 26

Expert Comment

by:Nick67
Comment Utility

c) did some more research using google for: db application property customribbonid
that Nick pointed out, and found out a related piece of info that a form has
a ribbon property

True.  But if you are attacking the Ribbon on Form Open , then what  happens when you open a report?  What happens when you have no forms open? Or a query, or whatever.

You can have very granular control.  But then you also must make very many decisions.  The use of the DevelopmentLibrary module to set the global Ribbon makes the myriad decisions less needful.  The downside is that whatever choice you make ONLY goes into effect on the next opening of the db.

Put it into production mode.
Close the db
Reopen it.
Is it good?
Close/reopen
Still good?

Toggle to dev mode.
Close/reopen
Is it showing everything again.

You cannot change the global Ribbon any time except on application open.
Changes done after application open will NOT take effect until the application is closed and reopened.

You can change the Ribbon displayed when an database object is opened on the fly, but not the global Ribbon.
0
 

Author Comment

by:mytfein
Comment Utility
Hi Nick,

tx so much for the info:

a) am using your accdb, so the references are there as screen shot below shows:
db
always thought that references apply across the board of the accdb, not just for vba
in modules, yet also for vba in forms/reports.....    

b) can you pls confirm if these statements, associate the number, with the id/row
in the UsysRibbonsTable?

SetApplicationProperty "CustomRibbonId", dbInteger, 1  - ribbon 1?
SetApplicationProperty "CustomRibbonId", dbInteger, 2  - ribbon 2?

c) below is revised mdb   (where in form event, form's ribbonName is being set

              and commented out my experiment of setApplicationProperty bec it
                    was giving me a syntax error)

d) also, if you run the form, then press alt+p, then exit accdb, then click on accdb
          you will see the form w/o default ribbons and navigation

    it looks like the quick access tool bar is there, yet options are grayed out
        so it form looks pretty good

            then if you press alt+t, accdb releases to test, i usually exit and go back in
                   i suppose i do not need alt+t, and could just go in with shift +click on file
                         yet i wanted to learn to do the toggle... and tx so much for explaining
                               about more than one ribbon.

tx so much, s
0
 

Author Comment

by:mytfein
Comment Utility
Hi Nick,

just as an aside, when i set mode to prod mode, the screen looks like this

s1
so if i click the file tab, a reduced file screens shows, that's fine

s2
however, if i want to see the form again, have to press the file tab again....
      just was wondering if that's the norm...

tx so much, s
0
 

Author Comment

by:mytfein
Comment Utility
HI Nick,

am uploading the db you provided in the first post

cannot find OnMainLoad  in UsysRibbons table or rest of vba....

maybe you decided not to include it in the approach?
s1
below is the 1st db that you provided below....

tx so much, sandra
Nick-post1.accdb
0
 
LVL 26

Expert Comment

by:Nick67
Comment Utility

always thought that references apply across the board of the accdb, not just for vba
in modules, yet also for vba in forms/reports.....    

They do.
Looking more closely at your syntax error screenshot, you are trying to call functions from DevelopmentLibrary from the form.  The functions and subs in DevelopmentLibrary will have to be declared a Public and not Private for that to work.  Are they?


b) can you pls confirm if these statements, associate the number, with the id/row
in the UsysRibbonsTable?

SetApplicationProperty "CustomRibbonId", dbInteger, 1  - ribbon 1?
SetApplicationProperty "CustomRibbonId", dbInteger, 2  - ribbon 2?

Correct.


so if i click the file tab, a reduced file screens shows, that's fine

It may not be.  Click on Privacy Options.  D'Oh!
But you have all the possible BackStage items from other posts.
Put all of them in HideTheRibbon, with visible = false


just was wondering if that's the norm...

Yup!
0
 
LVL 26

Expert Comment

by:Nick67
Comment Utility
Check the sample from this Q
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_28129836.html

That is what I was referring to
0
 
LVL 26

Expert Comment

by:Nick67
Comment Utility
And after you've got all the BackStage items in there and are certain you've got it right, you'll see that the system assiduously ignores the fact that you want nothing in the BackStage, and continues to show the Print tab and Privacy options.

And then you'll see where the accdr discussion came from.
Mind you, your sample is VERY unhappy being named an accdr on my system
0
 

Author Comment

by:mytfein
Comment Utility
HI Nick,

a) tx for that catch,  you are right the SetApplicationProperty was set to Private sub
    so i changed it to Public, and syntax error no longer shows

b)  i understand what you mean by granular ribbon vs. global ribbon

so i:

so i commented out setting the form's ribbon name  to using the SetApplicationProperty
in the form's open event

    then went into view mode form

    then clicked alt+p

    then exited db

    then clicked on db and home ribbon is still there

           (the file tab is what ribbon 1 row sets it too....)

but when i use the form.ribbon name = "HideTheRibbon", only the abbreviated
file tab shows....all other tabs are hidden....which as what would like to happen with the
Application property....

tx so much, s

t
2013-05-31m.ribbon.bmp
2013-05-31-Nick-EE.accdb
0
 

Author Comment

by:mytfein
Comment Utility
Hi Nick,

i understand... and now understand the related posts written by others on EE....

so are you saying that people tinker with USysRibbons   AND   convert to ACCDR

bec. i thought if you convert to ACCDR w/o doing anything else than ribbons etc. are

hidden....

i leave early on Fridays.... tx sooo much for your help...

you are amazing, s
0
 
LVL 26

Expert Comment

by:Nick67
Comment Utility
No ACCDR, the R stands for Run-time.  By naming the file so, you tell full-blown Access to run the file as if it were only the run-time Access.  The run-time does not provide facilities for creating objects, changing code and many other things.  Since the stupid Ribbon is so context sensitive, many of the things that we'd prefer the end user not to monkey with therefore become completely hidden because the run-time provides no facilities to screw around with them.

Doesn't mean that you still don't have to screw with USysRibbons though, but it is an adjunct to it.

And if the end-user has the smarts to rename ACCDR back to ACCDB then they can get around it ... unless the programmer then codes to detect if the file is being run in run-time mode -- and cuts the smarty-pantses off at the knees.

Sigh.

It'd be simpler if MS would just give us what we want
<CustomUI>
<Ribbon noFrigginRibbon = "true"><QAT noFrigginQAT = "true"></QAT></Ribbon>
<BackStage noFrigginBackStage = "true"></BackStage>
</CustomUI>

But alas, 7 years and three versions in and we still can't use that syntax
0
 

Author Comment

by:mytfein
Comment Utility
tx Nick for the explanation!   s
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now