Hiding the navigation pane

谁都会走 提交于 2021-01-28 08:50:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!