隐藏导航窗格

Posted

技术标签:

【中文标题】隐藏导航窗格【英文标题】:Hiding the navigation pane 【发布时间】:2017-11-24 15:12:07 【问题描述】:

好的,所以我需要但很挣扎。

我正在使用一个模块来隐藏它并尝试了以下但无济于事:

DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide

我也试过了:

 DoCmd.SelectObject acTable, , False

两者都不起作用 - 有什么想法吗?

【问题讨论】:

只是取消选中该选项? ***.com/a/24638829/3820271 第一个选项对我有用。你能详细说明什么不起作用吗?它会给出错误吗?你是如何运行它的? 第一个选项只有在没有其他对象打开的情况下才能可靠地工作。如果有默认表单,请将其添加到该表单的 Form_Load 事件中。 【参考方案1】:

试试这个:

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

如果这不起作用,请使用存在的表名,而不是跳过 docmd.selectobject 中的第二个参数

【讨论】:

【参考方案2】:

HideNavPane()

我发现如果当前在导航窗格中设置了搜索过滤器,其他示例中建议的代码将失败。在某些情况下,这会导致活动表单关闭。这可能会导致糟糕的用户体验。这个例程应该可以解决这个问题。

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

【讨论】:

以上是关于隐藏导航窗格的主要内容,如果未能解决你的问题,请参考以下文章

隐藏windows 10导航窗格不常用6个文件夹

如何快速自定义Win10文件资源管理器界面

通过 vba 访问更改导航窗格组

如何在eclipse中打开导航窗格?

无法调整 Access 2007 导航窗格的大小

在 MS Access 中禁用 F11 键以防止打开导航窗格