问题
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?
回答1:
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
回答2:
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
来源:https://stackoverflow.com/questions/47475999/hiding-the-navigation-pane