Results 1 to 12 of 12
  1. #1
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    7

    Hide Ribbon Works Sometimes

    Access 2016 trying to hide ribbon


    I have the following code in the load event of the startup module:
    DoCmd.ShowToolbar "Ribbon", acToolbarNo
    This works when I open the software in the safe mode (holding the shift key) and cycle between the form view and the design view of the module
    It does not work when I open the when I open the accdb version directly without the shift key
    It does not work when I open the accde version of the software.

    Any ideas?

    Thanks

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    That code should work if used at the correct time.
    You can have a startup form and/or an autoexec macro at startup but not a startup module.

    The fact that it works when you bypass startup code using the shift key but not otherwise suggests other code used at startup is conflicting with this
    Try moving the code as a function to an autoexec macro

    In case its useful, here are all my ribbon functions. Place in a standard module.

    Code:
    Option Compare Database
    Option Explicit
    'Functions to manage ribbon appearance
    Public Function HideRibbon()
        'could run at startup using Autoexec
        'however this also hides the QAT which makes printing reports tricky
         DoCmd.ShowToolbar "Ribbon", acToolbarNo
       '  DoCmd.ShowToolbar "PrintReport", acToolbarYes
    End Function
    
    
    Public Function ShowRibbon()
        'use when opening a report to display print preview ribbon
         DoCmd.ShowToolbar "Ribbon", acToolbarYes
    End Function
    
    
    Public Function ToggleRibbonState()
    'hide ribbon if visible & vice versa
        CommandBars.ExecuteMso "MinimizeRibbon"
    End Function
    
    
    Public Function IsRibbonMinimized() As Boolean
        'Result: 0=normal (maximized), -1=autohide (minimized)
        IsRibbonMinimized = (CommandBars("Ribbon").Controls(1).Height < 100)
       ' Debug.Print IsRibbonMinimized
    End Function
    
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    7
    This works when I open the software in the safe mode (holding the shift key) and cycle between the form view and the design view of the module
    It does not work when I open the when I open the accdb version directly without the shift key
    It does not work when I open the accde version of the software.

    The subroutines with the name prefixed with cmd are called by a form. I added Msgbox to verify that I entered the function. I have nothing else in the project, just the calling form; no files, queries, reports or other modules. I can't figure out why it works only when i go from the design view to the form view.

    I have the 2016 version of Access

    Code:
    Option Compare Database
    
    Private Sub cmdHideRibbon_Click()
    ' DoCmd.ShowToolbar "Ribbon", acToolbarNo
    
    
    HideRibbon
    End Sub
    
    
    Private Sub cmdShowRibbon_Click()
    ' DoCmd.ShowToolbar "Ribbon", acToolbarYes
    
    
    ShowRibbon
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
    MsgBox "open"
    ' DoCmd.ShowToolbar "Ribbon", acToolbarNo
    HideRibbon
    End Sub
    
    
    Public Function HideRibbon()
    MsgBox "hide"
        'could run at startup using Autoexec
        'however this also hides the QAT which makes printing reports tricky
         DoCmd.ShowToolbar "Ribbon", acToolbarNo
       '  DoCmd.ShowToolbar "PrintReport", acToolbarYes
    End Function
    
    
    
    
    Public Function ShowRibbon()
    MsgBox "show"
        'use when opening a report to display print preview ribbon
         DoCmd.ShowToolbar "Ribbon", acToolbarYes
    End Function
    
    
    
    
    Public Function ToggleRibbonState()
    'hide ribbon if visible & vice versa
        CommandBars.ExecuteMso "MinimizeRibbon"
    End Function
    
    
    
    
    Public Function IsRibbonMinimized() As Boolean
        'Result: 0=normal (maximized), -1=autohide (minimized)
        IsRibbonMinimized = (CommandBars("Ribbon").Controls(1).Height < 100)
       ' Debug.Print IsRibbonMinimized
    End Function

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    OK try the following.
    Make sure your form has been set as the startup form.
    Move the code in Form_Open to the Form_Load event and remove all the message box lines.

    If it still fails, instead run the HideRibbon function from an Autoexec macro

    NOTE:
    Make sure the code I supplied is in a standard module NOT your form module

    If you still can't get it to work reliably, upload a zipped copy of your dB and I'll have a look
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    7
    Make sure your form has been set as the startup form.
    Done.

    Move the code in Form_Open to the Form_Load event and remove all the message box lines.


    Moved the code to Form Load but it kept the functions intact; they are still independent modules. Removed the Msgbox from each.

    If it still fails, instead run the HideRibbon function from an Autoexec macro.
    This didn’t help

    NOTE:
    Make sure the code I supplied is in a standard module NOT your form module.

    If you still can't get it to work reliably, upload a zipped copy of your dB and I'll have a look.
    A zipped copy is attached. As before it works when I open the module while holding the shift key and cycle between the form view and design view. It does not work when I open the accdb or accde module directly.
    Because Access is more that the allowable size to upload I moved it to a Google Drive.
    https://drive.google.com/drive/folde...rk?usp=sharing

    Thanks for your help.
    Carl
    Attached Files Attached Files

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Unable to open the attached file. Zip file has an issue and doesn't seem to be complete.
    I don't normally look at externally hosted files but made an exception this time.
    However, also had a problem with the external file and can't view that either.
    Could you please redo the zip file and upload it to the forum again
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    7

    Hide Ribbon Works Sometimes

    Quote Originally Posted by isladogs View Post
    Unable to open the attached file. Zip file has an issue and doesn't seem to be complete.
    I don't normally look at externally hosted files but made an exception this time.
    However, also had a problem with the external file and can't view that either.
    Could you please redo the zip file and upload it to the forum again
    Re-did the zip. also included the file before zip. I don't know what is happening.

  8. #8
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    7

    Hide Ribbon Works Sometimes

    Quote Originally Posted by carlhiker View Post
    Re-did the zip. also included the file before zip. I don't know what is happening.
    Re-did the zip. also included the file before zip. I don't know what is happening.

  9. #9
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    7
    Redid the Zip, also included the unzipped software. Will that help?

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    i eventually managed to open your file but found several problems
    1. There were three missing references. - none were needed so I removed them
    2. You did not have Option Explicit in each code module
    2. The autoexec macro had a space after HideRibbon so the function didn't run

    After fixing each of those, it still failed. Its likely your form is corrupted.

    So I created a new database with a form frmRibbon , autoexec macro and module modRibbon.
    It works perfectly for me - ATTACHED

    If you haven't already seen it, suggest you look at my example app which shows how to control the application interface including ribbon, navigation pane, taskbar and application window. See http://www.mendipdatasystems.co.uk/c...ace/4594365418
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    7
    Obviously there is a problem in my coding. Your example works but when i incorporate the code in my software it doesn't. The compiler doesn't give any errors. How can i find the missing references? Also, how does one find how a form is corrupted? The form has only two buttons.

    Thank you for your help, the problem is in my ball park. I will consider this problem solved and mark it as such when i figure out how to do it.

    Thanks for your time!

    carl

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by carlhiker View Post
    Obviously there is a problem in my coding. Your example works but when i incorporate the code in my software it doesn't. The compiler doesn't give any errors. How can i find the missing references? Also, how does one find how a form is corrupted? The form has only two buttons.
    1. To check for missing references, open the VBE go to Tools...References. If any are marked MISSING, you need to browse to the file & select it.
    After doing this, compile your app (Debug...Compile) & fix any compile errors

    2. Corrupted forms cause errors that are hard to pin down.
    Make a backup before you proceed ...just in case
    Sometimes the code is corrupted. Decompiling can fix that - see http://www.fmsinc.com/microsoftacces.../decompile.asp.
    If it works, recompile then compact
    If decompiling doesn't help, its likely the form itself is corrupted in which case you may need to create a fresh copy of the form.

    Good luck
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hide the ribbon
    By UT227 in forum Access
    Replies: 1
    Last Post: 03-08-2019, 02:21 PM
  2. Hide the Ribbon Hot Key
    By Paul H in forum Access
    Replies: 4
    Last Post: 10-07-2015, 12:48 PM
  3. Ribbon Hide
    By msaccessdev in forum Programming
    Replies: 2
    Last Post: 10-27-2014, 12:13 PM
  4. Open form only, hide the ribbon bar.
    By kcmiuser in forum Access
    Replies: 3
    Last Post: 05-22-2013, 02:04 PM
  5. Un-hide Ribbon
    By mattellenburg in forum Access
    Replies: 0
    Last Post: 12-08-2011, 02:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums