"Display Navigation Pane"

Alc

Registered User.
Local time
Yesterday, 23:10
Joined
Mar 23, 2007
Messages
2,421
At present, I use the Navigation Pane for development, but hide it before it goes out to the users. Not that they can't unhide it, if they know how, but it stops 90% of users from messing around with data directly in the tables.

What I was wondering was if there's a simple command in VBA that would do the same thing. If so, I could have the application automatically show the navigation window if I open it (based on my computer name, already being picked up and used elsewhere) and hide the navigation for all others.

This is just a lazy way to avoid having to check the option, close and reopen every time I need to make a change.
 
Code:
' pass True or nothing to hide
' pass false to unhide
Public Sub HideNavigationPane(Optional bolHide As Boolean = True)
    If bolHide Then
        DoCmd.NavigateTo "acNavigationCategoryObjectType"
        DoCmd.RunCommand acCmdWindowHide
    Else
        DoCmd.SelectObject acTable, DBEngine(0)(0).TableDefs(0).Name, True
    End If
End Sub
 
This is just a lazy way to avoid having to check the option, close and reopen every time I need to make a change.
You could try holding Shift during database startup. Then you wont have to mess with any security in place. The down side is (almost) everyone knows this trick.:D

Edit: I had shift and f11, shift only is the correct way.
 
Last edited:
Code:
' pass True or nothing to hide
' pass false to unhide
Public Sub HideNavigationPane(Optional bolHide As Boolean = True)
    If bolHide Then
        DoCmd.NavigateTo "acNavigationCategoryObjectType"
        DoCmd.RunCommand acCmdWindowHide
    Else
        DoCmd.SelectObject acTable, DBEngine(0)(0).TableDefs(0).Name, True
    End If
End Sub

Thanks very much for the response, however when I run it I get the error message
Code:
 Run -time error '2544'
  
 Microsoft Access cannot find the ~TMPCLP119501 you referenced in the Object Name argument
Debug shows the problem is with this line
"DoCmd.SelectObject acTable, DBEngine(0)(0).TableDefs(0).Name, True"
 
You could try holding Shift during database startup. Then you wont have to mess with any security in place. The down side is (almost) everyone knows this trick.:D

Edit: I had shift and f11, shift only is the correct way.
Thanks, I was looking to get around that. Just curious if it could be done programmatically. The users are unlikely to open the database this way, but who knows what goes through their minds?
 
Code:
' pass True or nothing to hide
' pass false to unhide
Public Sub HideNavigationPane(Optional bolHide As Boolean = True)
    Dim td As DAO.TableDef
    If bolHide Then
        DoCmd.NavigateTo "acNavigationCategoryObjectType"
        DoCmd.RunCommand acCmdWindowHide
    Else
        For Each td In DBEngine(0)(0).TableDefs
            If InStr(td.Name, "~") = 0 Then
                DoCmd.SelectObject acTable, td.Name, True
                Exit For
            End If
        Next
        Set td = Nothing
    End If
End Sub
 
Perfect! Thanks very much
 

Users who are viewing this thread

Back
Top Bottom