,所以我需要隐藏导航窗格,但挣扎。
我正在使用模块隐藏它并尝试了以下内容,但无济于事:
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide
我也尝试了:
DoCmd.SelectObject acTable, , False
不工作 - 有什么想法吗?
trone this:
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand (acCmdWindowHide)
如果这不起作用,请使用存在的表名称,而不是跳过DocMd.SelectObject中的第二个参数。 Hidenavpane()
I发现,如果当前在导航窗格中设置了搜索过滤器,则其他示例中建议的代码将失败。 在某些情况下,这会导致主动形式关闭。 这可能会导致不良的用户体验。 这个例程应该解决。
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
this解决方案:
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand (acCmdWindowHide)
在这种情况下,解决方案是取消模态,然后像这样还原:
Me.Modal = False
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand (acCmdWindowHide)
Me.Modal = True