Hiding the navigation pane
Asked Answered
F

2

3

OK, so I need to hide the navigation pane but struggling.

I am using a module to hide it and have tried the following but to no avail:

DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide

I have also tried:

 DoCmd.SelectObject acTable, , False

Neither are working - Any ideas?

Federalism answered 24/11, 2017 at 15:12 Comment(3)
Just untick the option? https://mcmap.net/q/1857821/-displaying-an-access-gui-without-the-default-access-frameBoyt
That first option works for me. Can you elaborate on what doesn't work? Does it give an error? How are you running it?Spirituel
The first option only works reliably if no other objects are open. If there is a default form, add it to the Form_Load event for that form.Sweetbread
O
3

try this:

 DoCmd.SelectObject acTable, , True
 DoCmd.RunCommand (acCmdWindowHide)

if that doesn't work, use a table name that exists instead of skipping that second argument in docmd.selectobject

Omaromara answered 27/11, 2017 at 20:48 Comment(0)
A
3

HideNavPane()

I found that the code suggested in other examples would fail if a search filter was currently set in the navigation pane. In some cases this would cause the active form to close. That can lead to a bad user experience. This routine should get around that.

Public Sub HideNavPane()
' This will hide the Navigation Pane.
' It works even if a search filter is set, unlike other solutions that may
' inadvertently close the active object.
' Limitations:  An object (form, report, query, etc) must be open and it 
'               cannot be the same name as the selected item in the nav pane
'               or this will do nothing.
  
    Dim strCurrentObjectName As String
    
    strCurrentObjectName = Application.CurrentObjectName
      
    ' Move focus to the navigation pane/database container
    DoCmd.NavigateTo ("acNavigationCategoryObjectType")
  
    If strCurrentObjectName <> Application.CurrentObjectName Then
        ' The Navigation Pane is open and has focus.
        ' Use the window menu to hide the navigation pane
        DoCmd.RunCommand acCmdWindowHide
    End If
  
End Sub
Amandine answered 23/8, 2020 at 3:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.