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