Results 1 to 6 of 6

Hide Ribbon Works Sometimes

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

    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 Very idle programmer
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    3,613
    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 (Mendip Data Systems) : Website, email
    If this has helped, please click the star button and leave a comment

  3. #3
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    3
    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 Very idle programmer
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    3,613
    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 (Mendip Data Systems) : Website, email
    If this has helped, please click the star button and leave a comment

  5. #5
    carlhiker is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Sep 2019
    Posts
    3
    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 Very idle programmer
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    3,613
    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 (Mendip Data Systems) : Website, email
    If this has helped, please click the star button and leave a comment

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
  •  
Tech Forums: Microsoft Office Forums