Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Access VBA - Hiding Navigation panes

Hi

I am using the following code to hide the navigation panes in an Access database on the load event of my main form.
One problem that I have is that without navigation how will I go in to see my Visual Basic code.
I only want to activate this code when I give it to a user. Am I going about things correctly here?

Private Sub Form_Load()
    Call oHide_Navigation(True)
End Sub

Sub oHide_Navigation(ByVal blnHide As Boolean)
    On Error GoTo EH
    
    If blnHide = True Then
        'To hide the ribbon, add this code to your form's OnOpen event.
        DoCmd.ShowToolbar "Ribbon", acToolbarNo
    Else
        'To restore it:
        DoCmd.ShowToolbar "Ribbon", acToolbarYes
    End If
    
    If blnHide = True Then
        'To Hide the Navigation pane via vba code, you can use:
        DoCmd.NavigateTo "acNavigationCategoryObjectType"
        DoCmd.RunCommand acCmdWindowHide
    Else
        'And to bring it back:
        DoCmd.SelectObject acTable, "MSysObjects", True
    End If
   
    Exit Sub
EH:
    MsgBox "There was an error trying to hide/show the Access navigation" & Err.Description & " nb5"
End Sub

Open in new window

SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks very much