Determine open/close of Navigation Pane in A2007 (1 Viewer)

mdlueck

Sr. Application Developer
Local time
Today, 12:55
Joined
Jun 23, 2011
Messages
2,631
I have not come across a VBA way to determine if the Navigation Pane of Access 2007 is open/shut.

I understand that it may be toggled via sending the F11 keystroke.

Does anyone know a way to programmatically make sure it is closed (at application startup) and if someone wishes to open it, they may?
 

Alansidman

AWF VIP
Local time
Today, 11:55
Joined
Jul 31, 2008
Messages
1,493
Click on the office button in the upper left corner. Click on Access Options. Click on Current Database. Scroll down to Navigation and uncheck the box. Click ok. Close the db. If you need to see the Navigation Pane, then F11 will open it.
 

mdlueck

Sr. Application Developer
Local time
Today, 12:55
Joined
Jun 23, 2011
Messages
2,631
Yes I know how to hide it via the DB settings.

As certain forms open, I would simply like to make sure it is minimized so that the form may open using the entire screen. I do not want to actually completely hide the Navigation Pane... "Ease the folks off of getting into the bowels of databases!" ;) Thus keep snapping it shut if they should open it.
 

vbaInet

AWF VIP
Local time
Today, 17:55
Joined
Jan 22, 2010
Messages
26,374
Is there any point in checking if you can shut it in startup? Why not just shut it at startup before opening any form?

I don't think there's a non-API way of checking the open state of the Nav Pane.
 

mdlueck

Sr. Application Developer
Local time
Today, 12:55
Joined
Jun 23, 2011
Messages
2,631
Is there any point in checking if you can shut it in startup? Why not just shut it at startup before opening any form?

And not just at start-up, but perhaps for gigantic forms in this application as well... make sure the user did not open it and thus have less screen space than I would anticipate.

I don't think there's a non-API way of checking the open state of the Nav Pane.

Does that mean there is an API way to check its status and to minimize it as well? If so, please do tell!
 

mdlueck

Sr. Application Developer
Local time
Today, 12:55
Joined
Jun 23, 2011
Messages
2,631
When you set it at start up, save it in a variable and check against the variable afterwards. Have a look at post #4 here:

Which is:

What code do you have?

Two ways:

1.
Code:
    If NavIsHidden Then
        DoCmd.SelectObject acForm, , True
        NavIsHidden = False
    Else
        DoCmd.NavigateTo "acNavigationCategoryObjectType"
        [COLOR=Red]DoCmd.RunCommand acCmdWindowHide[/COLOR]
        NavIsHidden = True
    End If
where NavIsHidden is a variable that holds the state of the hidden value of the Nav Pane.

OR

2. Tweak the code above and when it comes to unhiding, trap the error if you can't acCmdWindowUnHide, then Resume to the SelectObject code.

The LOC in red is to completely hide it, not simply force it minimized. I checked the acCmdWindow* constants and there is not one to minimize it.
 

nanscombe

Registered User.
Local time
Today, 17:55
Joined
Nov 12, 2011
Messages
1,082
I'm afraid I blindly Sendkeys "{F11}" in the OnOpen and OnClose event of a large form. :D
 

Alansidman

AWF VIP
Local time
Today, 11:55
Joined
Jul 31, 2008
Messages
1,493
If you wanted to put command buttons on each form to hide or unhide as a solution, then I found this code that may work for you.

Code:
I have 2 command buttons on a form that Show or Hide the Navigation Pane (i.e. the shutter bar on the left side of the Access 2007 window). They work nicely for me.

The VBA behind the 2 command buttons is …

Private Sub cmdShowNavigationPane_Click()
DoCmd.SelectObject acTable, , True
End Sub

Private Sub cmdHideNavigationPane_Click()
DoCmd.NavigateTo “acNavigationCategoryObjectType”
DoCmd.RunCommand acCmdWindowHide
End Sub
 

spikepl

Eledittingent Beliped
Local time
Today, 18:55
Joined
Nov 3, 2010
Messages
6,142
How could one possibly check whether there is an answer to this question on this site .. hmmm ... anyone have a clue?
 

vbaInet

AWF VIP
Local time
Today, 17:55
Joined
Jan 22, 2010
Messages
26,374
@mdlueck: To minimize the Navigation window you can use:
Code:
    DoCmd.NavigateTo "acNavigationCategoryObjectType"
    DoCmd.Minimize
If you want to test, you can use the method I explained above or use SelectObject to select any object and trap the error. If it fails then the window is minimized.
 

mdlueck

Sr. Application Developer
Local time
Today, 12:55
Joined
Jun 23, 2011
Messages
2,631
FINALLY!!!! :eek:

Thank you so much vbaInet, and still did not have to stoop to using SendKeys! :D
 

CNW

New member
Local time
Today, 11:55
Joined
Mar 11, 2013
Messages
1
I am using Access 2010 32 bit.
I thought I would share my solution in the hopes it might direct someone else.
I have a multi-tab form. There is one tab on the form that causes issues if the Nav Pane is open due to fact that I hide split form and increase size of form. If Nav Pane is open there is not sufficient room to do this so throws an error. My problem was how to evaluate if Nav Pane was open. To resolve I did the following:
#1 Drop a hidden unbound text box on my main form, set the data control source to "=[Forms].[f_cont].[WindowWidth]" to capture initial window width value. This is the only method I found to determine if the width had changed. FormWidth did not work.
#2 Create a tab event on the problem tab as follows:
Dim StWinWidth As Integer ' Variable to store current value of Forms.f_Cont.WindowWidth
If intTabValue = 1 Then ' Looks at which tab is clicked.
StWinWidth = Forms.f_Cont.WindowWidth ' Sets value of stWinWidth (start window width) to current window.
If StWinWidth < (Me.IniWinSize - 1000) Then ' If value is less than 1000 of initial open value execute following code, if not skip past.
Forms!f_Cont.Form.Contacts.SetFocus ' If on a subform must shift back to the main form for the focus to shift to Nav Pane.
DoCmd.NavigateTo "acNavigationCategoryObjectType" ' Shifts focus to Nav Pane.
DoCmd.RunCommand acCmdWindowHide 'Hides Nav Pane.

Hope this helps. Thank you to this forum for many good suggestions!
 

Samantha

still learning...
Local time
Today, 12:55
Joined
Jul 12, 2012
Messages
180
@mdlueck: To minimize the Navigation window you can use:
Code:
    DoCmd.NavigateTo "acNavigationCategoryObjectType"
    DoCmd.Minimize

vbaInet,

Where would I insert this code at? on each form or can I do this globally?

Samantha
 

mdlueck

Sr. Application Developer
Local time
Today, 12:55
Joined
Jun 23, 2011
Messages
2,631
Where would I insert this code at? on each form or can I do this globally?

The way I have implemented it: Both! ;)

Code on each form:

Code:
Private Sub Form_Load()
  On Error GoTo Err_Form_Load

[B]  'Call shared code to make sure the form is set properly
  Call uiutils_ResetForm(Me)
[/B]
  'Rest of form event...

Exit_Form_Load:
  Exit Sub

Err_Form_Load:
  Call errorhandler_MsgBox("Form: " & TypeName(Me) & ", Subroutine: Form_Load()")
  Resume Exit_Form_Load

End Sub
Code:
Sub uiutils_ResetForm(ByRef MePointer As Access.Form)
  On Error GoTo Err_uiutils_ResetForm

  [B]'Make sure the Navigation Pane is minimized
  DoCmd.NavigateTo Category:="acNavigationCategoryObjectType"
  DoCmd.Minimize
[/B]
  'Make sure the Ribbon is minimized
  If MePointer.Application.CommandBars.Item("Ribbon").Height > 80 Then
    SendKeys "^{F1}", False
    DoEvents
  End If

  'Rest of module subroutine...

Exit_uiutils_ResetForm:
  Exit Sub

Err_uiutils_ResetForm:
  Call errorhandler_MsgBox("Module: modshared_uiutils, Function: uiutils_ResetForm()")
  Resume Exit_uiutils_ResetForm

End Sub
 

Users who are viewing this thread

Top Bottom