Ever wanted to minimize/close the Navigation Pane/Shutter Bar? Not hide it completely, just make it minimize/close/collapse. Below is a simple sub that enables you to do so.
'---------------------------------------------------------------------------------------
' Procedure : Nav_Collapse
' Author : Daniel Pineault, CARDA Consultants Inc.
' Website : http://www.cardaconsultants.com
' Purpose : Close/Minimize the main navigation pane/shutter bar
' Copyright : The following is release as Attribution-ShareAlike 4.0 International
' (CC BY-SA 4.0) - https://creativecommons.org/licenses/by-sa/4.0/
' Req'd Refs: None required
'
' Usage:
' ~~~~~~
' Call Nav_Collapse
'
' Revision History:
' Rev Date(yyyy/mm/dd) Description
' **************************************************************************************
' 1 2019-01-11 Initial Release
'---------------------------------------------------------------------------------------
Public Sub Nav_Collapse()
On Error GoTo Error_Handler
DoCmd.SelectObject acModule, , True
DoCmd.Minimize
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: Nav_Collapse" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occurred!"
Resume Error_Handler_Exit
End Sub
Inversely, should you wish to expand the Navigation Pane/Shutter Bar back to it’s original state, then you can use the following sub routine.
'---------------------------------------------------------------------------------------
' Procedure : Nav_Expand
' Author : Daniel Pineault, CARDA Consultants Inc.
' Website : http://www.cardaconsultants.com
' Purpose : Open/Restore the main navigation pane/shutter bar to its previous state
' Copyright : The following is release as Attribution-ShareAlike 4.0 International
' (CC BY-SA 4.0) - https://creativecommons.org/licenses/by-sa/4.0/
' Req'd Refs: None required
'
' Usage:
' ~~~~~~
' Call Nav_Expand
'
' Revision History:
' Rev Date(yyyy/mm/dd) Description
' **************************************************************************************
' 1 2019-01-11 Initial Release
'---------------------------------------------------------------------------------------
Public Sub Nav_Expand()
On Error GoTo Error_Handler
DoCmd.SelectObject acModule, , True
DoCmd.Maximize
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: Nav_Expand" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occurred!"
Resume Error_Handler_Exit
End Sub
If you are looking to hide the Navigation Pane altogether then refer to my original article on the subject MS Access – VBA – Hide the Navigation Pane.
I prefer to use DoCmd.NavigateTo “acNavigationCategoryObjectType” instead, because when you force the Navigation Pane to open by using DoCmd.SelectObject to select a module, you end up… selecting a module. The first entry in the Modules list becomes the currently selected item in the Navigation Pane. By contrast, using DoCmd.NavigateTo does not alter the current selection in the Navigation Pane.
Great tip. Thank you for sharing.