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

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
Just open the database holding Shift...this will disable the code
0
Dale FyeCommented:
I generally do something like:

If fOSUserName = "admin" Then
    'do nothing
else
    'hide nave pane
endif

if you are not famiiar with fOSUserName() you can download it from: http://www.access.mvps.org/access/api/api0008.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fabrice LambertFabrice LambertCommented:
Or alternatively, hit ctrl + F11 to bring up the VBA editor.

You can hide the navigation pane or ribbon, but keyboard shortcuts still work.
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.