Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBA - Is Access 2013 Navigation Pane Visible

Posted on 2014-04-17
9
Medium Priority
?
2,650 Views
Last Modified: 2014-04-17
I use the following code to hid the navigation pane:
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide

I use the following code to show the navigation pane:
DoCmd.SelectObject acTable, , True

What code do I use for:
Public Function IsNavigationPaneVisible() as boolean
dim fReturn as boolean
fReturn=?????
IsNavigationPaneVisible=fReturn
Exit Function
0
Comment
Question by:rmk
  • 5
  • 4
9 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 40006641
Not sure if this will work in A2013 or not.  Give it a shot:

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long

Private Declare Function isWindowVisible Lib "user32" Alias "IsWindowVisible" (ByVal hwnd As Long) As Long

Public Function isDbWindowVisible() As Boolean
Dim hWindow As Long
If Int(SysCmd(acSysCmdAccessVer)) >= 12 Then
hWindow = FindWindowEx(Application.hWndAccessApp, 0, "NetUINativeHWNDHost", vbNullString)
hWindow = FindWindowEx(hWindow, 0, "NetUIHWND", vbNullString)
Else
hWindow = FindWindowEx(Application.hWndAccessApp, 0, "MDIClient", vbNullString)
hWindow = FindWindowEx(hWindow, 0, "Odb", vbNullString)
End If
isDbWindowVisible = (isWindowVisible(hWindow) <> 0)
End Function
0
 

Author Closing Comment

by:rmk
ID: 40006719
That's exactly what I needed. THANKS !
0
 

Author Comment

by:rmk
ID: 40006748
Actually, I thing your code needs a couple of minor changes for VBA7, i.e. the Declare statement needs PtrSafe and the handles should be delcared as LongPtr instead of Long

Declare PtrSafe Function IsWindowVisible Lib "user32" Alias "IsWindowVisible" (ByVal hwnd As LongPtr) As Long

Dim hWindow As LongPtr
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rmk
ID: 40006917
It works fine when I open my application with the shift key depressed and then manually open the startup form called frmMain. I can use F11 to toggle the navigation pane and the code always returns the correct true or false value.

However the code always returns true when I open my application without the shift key depressed. There is no autoexec macro and the DisplayForm drop down list is set to frmMain. The only psuedo startup code is:

Public grbnForm                     As IRibbonUI
Public grbnBackStage                As IRibbonUI

Public Sub FormRibbonOnLoad(ribbon As IRibbonUI)
    Set grbnForm = ribbon
End Sub

Public Sub BackStageRibbonOnLoad(ribbon As IRibbonUI)
    Set grbnBackStage = ribbon
End Sub

Any ideas ?????
0
 
LVL 58
ID: 40006944
<<Actually, I thing your code needs a couple of minor changes for VBA7, i.e. the Declare statement needs PtrSafe and the handles should be delcared as LongPtr instead of Long>>

 That's only if your running 64 bit instead of 32 bit Office.

<<Any ideas ????? >>

 In frmMain, try an explicit hide of the nav pane, and then see if it starts returning the correct value.

Jim.
0
 

Author Comment

by:rmk
ID: 40007077
The explicit hide did not work.

Since 32 bit Office is running on 64 bit Windows, I thought all window handles were 64 bit and therefore had to be declared with PtrSafe as LongPtr. At least that's what it implies in Win32API_PtrSafe.txt that I downloaded as part of Office 2010 Developer Resources which has the following preambel
'
'             Win32API_PtrSafe.TXT -- Declare statements for
'         Visual Basic for Applications and Microsoft Office 2010
'
'              Copyright (C) 2010 Microsoft Corporation.
'                         All rights reserved.
'
'
' This file contains Declare statements for many functions in the
' Microsoft Windows API for use with Visual Basic for Applications (VBA)
' and Microsoft Office 2010 on 32-bit (x86) and 64-bit (x64) platforms.
'
' The declare statements in this file are not compatible with VB6 or
' previous versions of Microsoft Office. Refer to the Microsoft Windows
' Programmer's Reference for further information on the use of Windows APIs.
'
' You may use, modify, reproduce, and distribute this file (and/or any
' modified version), for use with any of the Microsoft technologies
' described above.  THIS FILE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY
' KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF
' FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
0
 
LVL 58
ID: 40007121
<<Since 32 bit Office is running on 64 bit Windows, I thought all window handles were 64 bit and therefore had to be declared with PtrSafe as LongPtr. At least that's what it implies in Win32API_PtrSafe.txt that I downloaded as part of Office 2010 Developer Resources which has the following preambel>>

 No, it's optional when making calls from 32 bit.  It's only required when your using 64 bit office. Read the section "Application Programming Interface Compatibility"  here:

http://msdn.microsoft.com/en-us/library/ee691831%28v=office.14%29.aspx

and note that:

"Note that the PtrSafe attribute is optional on the 32-bit version of Office 2010. This enables existing Declare statements to work as they always have. "

 as for why it's not working, I don't know.  I'd have to dig into it and don't have the time at the moment.

   I picked up the code somewhere just out of interest on the chance that I might use it some day.  Never tried it.

Jim.
0
 

Author Comment

by:rmk
ID: 40007211
I read your link carefully this time, and as usual you are correct.
BTW, I unchecked the  the Display Navigation Pane check box in Current Database Options and explicitly hide the navigation window in frmMain. Now the IsVisible function works properly.
You continue to be one of most valued resources - thank you for your superb support!
0
 
LVL 58
ID: 40007730
Glad to hear your squared away...

Jim.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question