Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

acCmdWindowHide has no effect

868 views
Skip to first unread message

Ken Warthen

unread,
Jan 6, 2009, 9:12:01 AM1/6/09
to
In the Form_Load event of my login form I test to see if the Navigation Pane
is visible and use the following line to hide it:

DoCmd.RunCommand acCmdWindowHide

The line seems to have no effect as it does not close or hide the Navigation
Pane. Does anybody have any idea on why this code would not work?

TIA,

Ken


Dirk Goldgar

unread,
Jan 6, 2009, 9:55:24 AM1/6/09
to
"Ken Warthen" <KenWa...@discussions.microsoft.com> wrote in message
news:7C4F3B27-40E1-43E9...@microsoft.com...


I don't have Access 2007 handy to test, but in earlier versions, when doing
the equivalent, you would have to first select something in the window you
want to hide, so you'd use code along these lines:

DoCmd.SelectObject acForm, Me.Name, True
RunCommand acCmdWindowHide

Did you do the SelectObject first?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Ken Warthen

unread,
Jan 6, 2009, 10:11:01 AM1/6/09
to
Dirk,

Thanks for your input. In my code I do select a table first. The Form_Load
event code looks like the following.

Private Sub Form_Load()
On Error GoTo PROC_ERROR

' Initialize the login attempts value
gLoginAttempts = 1

' If the Navigation Pane is visible, hide it
If isNavWindowVisible = True Then
DoCmd.SelectObject acTable, "tblTest", True
DoCmd.RunCommand acCmdWindowHide
End If

PROC_EXIT:
Exit Sub
PROC_ERROR:
Call ShowError("frmLogin", "Form_Load", Err.Number, Err.Description,
Err.Source)
Resume PROC_EXIT
Resume
End Sub

Dirk Goldgar

unread,
Jan 6, 2009, 10:54:49 AM1/6/09
to
"Ken Warthen" <KenWa...@discussions.microsoft.com> wrote in message
news:DD14F948-F851-4EDE...@microsoft.com...

> Dirk,
>
> Thanks for your input. In my code I do select a table first. The
> Form_Load
> event code looks like the following.
>
> Private Sub Form_Load()
> On Error GoTo PROC_ERROR
>
> ' Initialize the login attempts value
> gLoginAttempts = 1
>
> ' If the Navigation Pane is visible, hide it
> If isNavWindowVisible = True Then
> DoCmd.SelectObject acTable, "tblTest", True
> DoCmd.RunCommand acCmdWindowHide
> End If
>
> PROC_EXIT:
> Exit Sub
> PROC_ERROR:
> Call ShowError("frmLogin", "Form_Load", Err.Number, Err.Description,
> Err.Source)
> Resume PROC_EXIT
> Resume
> End Sub


That looks fine to me, but of course I can't see what goes on in
"isNavWindowVisible". Can you step through the code and verify that the
statements that hide the nav pane are actually executed?

Ken Warthen

unread,
Jan 6, 2009, 11:27:01 AM1/6/09
to
Dirk,

I have stepped through each line of code, and though Access appears to
execute the code to hide the Navigation Pane, it does not hide. It's all
very annoying. BTW, here's the code for isNavWindowVisible:

'API function to find a child window for an application handle
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
' API function that returns 1 if a window handle is visible, 0 if
invisible or the handle is zero
Private Declare Function isWindowVisible Lib "user32" Alias
"IsWindowVisible" (ByVal hwnd As Long) As Long


Public Function isNavWindowVisible() As Boolean
On Error GoTo PROC_ERROR
Dim hwnd As Long

If Val(SysCmd(acSysCmdAccessVer)) >= 12 Then
hwnd = FindWindowEx(Application.hWndAccessApp, 0,
"NetUINativeHWNDHost", vbNullString)
Else ' Database Browser is a subwindow of MDIClient inside of Access
' get Access MDI client Window
hwnd = FindWindowEx(Application.hWndAccessApp, 0, "MDIClient",
vbNullString)
' get the Access Database Window
hwnd = FindWindowEx(hwnd, 0, "Odb", vbNullString)
End If

isNavWindowVisible = (isWindowVisible(hwnd) <> 0)


PROC_EXIT:
Exit Function
PROC_ERROR:
Call ShowError("modAPI", "isNavWindowVisible", Err.Number,

Err.Description, Err.Source)
Resume PROC_EXIT
Resume

End Function

Dirk Goldgar

unread,
Jan 6, 2009, 3:32:19 PM1/6/09
to
"Ken Warthen" <KenWa...@discussions.microsoft.com> wrote in message
news:BDC4C366-5D7D-4E9E...@microsoft.com...

> Dirk,
>
> I have stepped through each line of code, and though Access appears to
> execute the code to hide the Navigation Pane, it does not hide. It's all
> very annoying.

Hmm, I just tested the basic code in Access 2007 and it worked fine. I'm
not sure what's going on here. Is there any other code executing, maybe in
a Timer event, that might show the nav pane again?

Ken Warthen

unread,
Jan 6, 2009, 3:49:01 PM1/6/09
to
Dirk,

There's nothing else going on, however, I discovered that if I have the
Display Document Tabs selected in Current Database options, the code works.
When I have the tabs option deselected the code does not work. There's no
logical reason why this would be so, but it appears to be true.

Ken

Dirk Goldgar

unread,
Jan 6, 2009, 4:10:02 PM1/6/09
to

"Ken Warthen" <KenWa...@discussions.microsoft.com> wrote in message
news:B3C59A8C-9AB4-4F1C...@microsoft.com...

> Dirk,
>
> There's nothing else going on, however, I discovered that if I have the
> Display Document Tabs selected in Current Database options, the code
> works.
> When I have the tabs option deselected the code does not work. There's no
> logical reason why this would be so, but it appears to be true.


Interesting, but I don't see the same behavior. I'm testing with a simple
form having code to hide the nav pane in its Open event:

DoCmd.SelectObject acForm, Me.Name, True
RunCommand acCmdWindowHide

I've tested it with the Document Window Options set to "Overlapping
Windows", to "Tabbed Documents" with "Display Document Tabs" checked, and to
"Tabbed Documents" with "Display Document Tabs" unchecked. In every case,
the nav pane is successfully hidden when the form is opened.

So there's something happening for you that is not happening for me. I have
SP1 applied; do you?

AccessVandal via AccessMonster.com

unread,
Jan 6, 2009, 10:42:35 PM1/6/09
to
Interesting.

Here’s my test. With SP1 applied.

In Access options – Current Database – Document Window Option, the default is
check on Overlapping Windows with disable “Display Document Tabs”

I ran the form in the OnOpen event. The Nav Pane is still visible.

Change to “Tabbed Documents”, the checkbox is now enable on the “Display
Document Tabs”, but leave the default enabled. Restart Access again.

I ran the form again. The Nav Pane is now hidden.

Back to Access Option, uncheck the “Display Document Tabs”. Restart Access
again.

I ran form again. The Nav Pane is still able to hide.

Back to Access Option, this time I will reset back to the original defaults.
Eg.
Check on “Overlapping Windows” and it will auto disable the “Display Document
Tabs”. Restart access again.

I ran the form again, this time the Nav Pane is able to hide.

It seems like Access2007 needs to do a run-in like car engines! Is MS tryng
to influence the automotive industries or copying them? LOL.


Dirk Goldgar wrote:
>> Dirk,


>Interesting, but I don't see the same behavior. I'm testing with a simple
>form having code to hide the nav pane in its Open event:
>
> DoCmd.SelectObject acForm, Me.Name, True
> RunCommand acCmdWindowHide
>
>I've tested it with the Document Window Options set to "Overlapping
>Windows", to "Tabbed Documents" with "Display Document Tabs" checked, and to
>"Tabbed Documents" with "Display Document Tabs" unchecked. In every case,
>the nav pane is successfully hidden when the form is opened.
>
>So there's something happening for you that is not happening for me. I have
>SP1 applied; do you?
>

--
Please Rate the posting if helps you

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200901/1

AccessVandal via AccessMonster.com

unread,
Jan 9, 2009, 3:24:31 AM1/9/09
to
Testing....
Weird, my post in reply to Dirk did not appear in PCReview.

Interesting.

Here’s my test. With SP1 applied.

In Access options – Current Database – Document Window Option, the default is
check on Overlapping Windows with disable “Display Document Tabs”

I ran the form in the OnOpen event. The Nav Pane is still visible.

Change to “Tabbed Documents”, the checkbox is now enable on the “Display
Document Tabs”, but leave the default enabled. Restart Access again.

I ran the form again. The Nav Pane is now hidden.

Back to Access Option, uncheck the “Display Document Tabs”. Restart Access
again.

I ran form again. The Nav Pane is still able to hide.

Back to Access Option, this time I will reset back to the original defaults.
Eg.
Check on “Overlapping Windows” and it will auto disable the “Display Document
Tabs”. Restart access again.

I ran the form again, this time the Nav Pane is able to hide.

It seems like Access2007 needs to do a run-in like car engines! Is MS tryng
to influence the automotive industries or copying them? LOL.

--

Dirk Goldgar

unread,
Jan 9, 2009, 2:47:57 PM1/9/09
to
"AccessVandal via AccessMonster.com" <u18947@uwe> wrote in message
news:8fcf42e5b1d9a@uwe...

> Interesting.
>
> Here’s my test. With SP1 applied.
>
> In Access options – Current Database – Document Window Option, the default
> is
> check on Overlapping Windows with disable “Display Document Tabs”
>
> I ran the form in the OnOpen event. The Nav Pane is still visible.
>
> Change to “Tabbed Documents”, the checkbox is now enable on the “Display
> Document Tabs”, but leave the default enabled. Restart Access again.
>
> I ran the form again. The Nav Pane is now hidden.
>
> Back to Access Option, uncheck the “Display Document Tabs”. Restart Access
> again.
>
> I ran form again. The Nav Pane is still able to hide.
>
> Back to Access Option, this time I will reset back to the original
> defaults.
> Eg.
> Check on “Overlapping Windows” and it will auto disable the “Display
> Document
> Tabs”. Restart access again.
>
> I ran the form again, this time the Nav Pane is able to hide.
>
> It seems like Access2007 needs to do a run-in like car engines! Is MS
> tryng
> to influence the automotive industries or copying them? LOL.


Well, this is odd. I can't reproduce that. There is no code in my form's
Open event but the code to select the form -- or a table, I've tried it both
ways -- in the database window, and then hide the window. In each case I
set the options, closed the database, reopened the database, and opened the
form. I tried it four ways:

+ Overlapping Windows, "Display Tabs" unchecked and disabled
--> the Nav Pane was hidden when I opened the form

+ Overlapping Windows, "Display Tabs" checked but disabled
--> the Nav Pane was hidden when I opened the form

+ Tabbed Documents, "Display Tabs" checked
--> the Nav Pane was hidden when I opened the form

+ Tabbed Documents, "Display Tabs" unchecked
--> the Nav Pane was hidden when I opened the form

I also tried the first variation with the form set as the database's startup
form, so that it opened automatically. This time, too, the navigation pane
was hidden. In that test, I exited Access completely, rather than just
closing and reopening the database.

I'm completely puzzled why yours isn't behaving the same way. Do you want
to send it to me, to see what it does here?

AccessVandal via AccessMonster.com

unread,
Jan 13, 2009, 5:18:11 AM1/13/09
to
Dirk,

>Well, this is odd. I can't reproduce that.

That's what I'm trying to say. I'm no longer able to reproduce this problem
too.

Once the Access Options is changed, it seems that it can't go back to the
original problem.

I'll try to go to the users whom are using A2007. Hopefully, they have never
use or configure their Access Options but these users are in another
locations. I may a couple days.

PS. Ok, I have create a new blank database called Test1.
1. Create new form - Onopen event use Docmd.RunCommand acCmdWindowHide.
2. Run the form, the nav pane is still visible.
3. Close the database.
4. Re-open the database.
5. Run the form - the nav pane is hidden.

It seem that you need to close the database before you can use the
acCmdWindowHide?

One my second test again with a new blank database called Test2, I could not
replicate this problem.

Weird?

Dirk Goldgar wrote:
>> Interesting.
>>
>[quoted text clipped - 28 lines]


>> tryng
>> to influence the automotive industries or copying them? LOL.
>
>Well, this is odd. I can't reproduce that. There is no code in my form's
>Open event but the code to select the form -- or a table, I've tried it both
>ways -- in the database window, and then hide the window. In each case I
>set the options, closed the database, reopened the database, and opened the
>form. I tried it four ways:
>
>+ Overlapping Windows, "Display Tabs" unchecked and disabled
> --> the Nav Pane was hidden when I opened the form
>
>+ Overlapping Windows, "Display Tabs" checked but disabled
> --> the Nav Pane was hidden when I opened the form
>
>+ Tabbed Documents, "Display Tabs" checked
> --> the Nav Pane was hidden when I opened the form
>
>+ Tabbed Documents, "Display Tabs" unchecked
> --> the Nav Pane was hidden when I opened the form
>
>I also tried the first variation with the form set as the database's startup
>form, so that it opened automatically. This time, too, the navigation pane
>was hidden. In that test, I exited Access completely, rather than just
>closing and reopening the database.
>
>I'm completely puzzled why yours isn't behaving the same way. Do you want
>to send it to me, to see what it does here?
>

--

Please Rate the posting if helps you

Message posted via http://www.accessmonster.com

Dirk Goldgar

unread,
Jan 13, 2009, 11:04:17 AM1/13/09
to
"AccessVandal via AccessMonster.com" <u18947@uwe> wrote in message
news:901e27086fe08@uwe...

>
> PS. Ok, I have create a new blank database called Test1.
> 1. Create new form - Onopen event use Docmd.RunCommand acCmdWindowHide.
> 2. Run the form, the nav pane is still visible.
> 3. Close the database.
> 4. Re-open the database.
> 5. Run the form - the nav pane is hidden.
>
> It seem that you need to close the database before you can use the
> acCmdWindowHide?

I just tested the same thing: new database, create form, add code to Open
event:

DoCmd.SelectObject acForm, Me.Name, True
RunCommand acCmdWindowHide

Close and save form, open form in form view, the nav pane was hidden. Go
figure.

> One my second test again with a new blank database called Test2, I could
> not
> replicate this problem.
>
> Weird?

Weird. It must be some timing problem.

AccessVandal via AccessMonster.com

unread,
Jan 13, 2009, 8:22:22 PM1/13/09
to
All my previous test are in Trusted Location and is without any hotfix.

On further test, I created a new database called Test3 in an Untrusted
Location.

Docmd failed to hide the nav pane 3 times. I enable the "Enable this content"
the security warnings, ran the form - the nav pane was hidden. It will not
work unless you enable the the content.

It seems that A2007 sometimes or at random have problems with macros even in
Trusted Locations?

In Trusted Center - Macro Settings - Disable all macros with notification.
Could this be the problem? But I don't think so. Unless these macros are in
untrusted location but than again.....I guess MS may have a problem to solve
in the next SP.

I don't it's the database file is the problem. The problem seems to manifest
in A2007/Vista installation.

Dirk Goldgar wrote:
>I just tested the same thing: new database, create form, add code to Open
>event:
>
> DoCmd.SelectObject acForm, Me.Name, True
> RunCommand acCmdWindowHide
>
>Close and save form, open form in form view, the nav pane was hidden. Go
>figure.
>

>Weird. It must be some timing problem.

--

Please Rate the posting if helps you

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200901/1

Dirk Goldgar

unread,
Jan 14, 2009, 11:11:51 AM1/14/09
to
"AccessVandal via AccessMonster.com" <u18947@uwe> wrote in message
news:90260c30b2a87@uwe...

> All my previous test are in Trusted Location and is without any hotfix.
>
> On further test, I created a new database called Test3 in an Untrusted
> Location.
>
> Docmd failed to hide the nav pane 3 times. I enable the "Enable this
> content"
> the security warnings, ran the form - the nav pane was hidden. It will not
> work unless you enable the the content.

Yes, of course. In an untrusted location, by default, no code will run, so
the code to hide the nav pane would not be executed.

> It seems that A2007 sometimes or at random have problems with macros even
> in
> Trusted Locations?

I wouldn't jump to the conclusion that what you're experiencing is a problem
with trust and code suppression. If you want to test that, though, you
could add a Debug.Print statement or a MsgBox call to the event procedure to
give clear indication of whether the code was executed.

> I don't it's the database file is the problem. The problem seems to
> manifest
> in A2007/Vista installation.

But I can't reproduce it, even using A2007 under Vista, so there seems to be
some specific condition that we haven't discovered.

AccessVandal via AccessMonster.com

unread,
Jan 14, 2009, 8:26:20 PM1/14/09
to
Dirk Goldgar wrote:
>I wouldn't jump to the conclusion that what you're experiencing is a problem
>with trust and code suppression. If you want to test that, though, you
>could add a Debug.Print statement or a MsgBox call to the event procedure to
>give clear indication of whether the code was executed.

Done that, the events were running fine with no error messages.

I decided to create two buttons on a form instead. (in trusted location)

1.Command0 button to hide nav pane - ok no problem and no errors.

2.Command1 button to unhide nav pane. Run-time Error '2046' The command or
action 'WindowUnhide' isn't available now. The Error is on DoCmd line but if
I add a line before the Docmd "On Error Resume Next" the nav pane was
unhidden!

Without the Resume Next the DoCmd will fail.

I'm really puzzle on this one.

There was another thread similiar with a docmd.quit that crash access which I
decided carry out this test.

--
Please Rate the posting if helps you.

AccessVandal via AccessMonster.com

unread,
Jan 15, 2009, 1:41:51 AM1/15/09
to
Dirk,

In addition to my previous post, users at another location exhibit the same
initial problem of hiding the nav pane on two machines.

I did not want to proceed further as it would be the same results on my end.

Both are box are running on HP Core 2 E6550 with 2 Gb of RAM on Win Vista
Business Ed. And MS Office Pro Plus 2007.

Dirk Goldgar wrote:

--
Please Rate the posting if helps you.

Dirk Goldgar

unread,
Jan 15, 2009, 1:48:03 AM1/15/09
to
"AccessVandal via AccessMonster.com" <u18947@uwe> wrote in message
news:9032a77a9fbe8@uwe...

>
> 2.Command1 button to unhide nav pane. Run-time Error '2046' The command or
> action 'WindowUnhide' isn't available now. The Error is on DoCmd line but
> if
> I add a line before the Docmd "On Error Resume Next" the nav pane was
> unhidden!
>
> Without the Resume Next the DoCmd will fail.
>
> I'm really puzzle on this one.


I'm guessing that your code for that button was incorrect. Did you maybe
write something like this:

DoCmd.SelectObject acTable, , True
RunCommand acCmdWindowUnhide

? If so, that explains the error. The act of selecting the object in the
database window "unhides" the window; after that, the window is not hidden
and so the RunCommand acCmdWindowUnhide statement will fail. All you need
to show the database window after you've hidden it is:

DoCmd.SelectObject acTable, , True

I've been reminded, since I originally wrote, that you don't actually need
to specify the name of an object when calling DoCmd.SelectObject to hide or
unhide the database window.

AccessVandal via AccessMonster.com

unread,
Jan 15, 2009, 4:35:25 AM1/15/09
to
Yes, but not a table as there none. I use the form.

So, are you saying after hiding the Nav Pane you can't use the RunCommand
acCmdWindowUnhide but use "DoCmd.SelectObject acTable, , True" or the form to
show the Nav Pane?

I wondering what acCmdWindowUnhide do or is redundant.

The problem of hiding the Nav Pane still hold true even at the user machine
as in Ken's problem. I did not proceed with the test as it will solve the
problem as in my end. I decide to leave it as it is.

Dirk Goldgar wrote:
>I'm guessing that your code for that button was incorrect. Did you maybe
>write something like this:
>
> DoCmd.SelectObject acTable, , True
> RunCommand acCmdWindowUnhide
>
>? If so, that explains the error. The act of selecting the object in the
>database window "unhides" the window; after that, the window is not hidden
>and so the RunCommand acCmdWindowUnhide statement will fail. All you need
>to show the database window after you've hidden it is:
>
> DoCmd.SelectObject acTable, , True
>
>I've been reminded, since I originally wrote, that you don't actually need
>to specify the name of an object when calling DoCmd.SelectObject to hide or
>unhide the database window.
>

--

Please Rate the posting if helps you.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200901/1

Dirk Goldgar

unread,
Jan 15, 2009, 9:56:48 AM1/15/09
to
"AccessVandal via AccessMonster.com" <u18947@uwe> wrote in message
news:9036ecd3adcce@uwe...

> Yes, but not a table as there none. I use the form.
>
> So, are you saying after hiding the Nav Pane you can't use the RunCommand
> acCmdWindowUnhide but use "DoCmd.SelectObject acTable, , True" or the form
> to
> show the Nav Pane?

Yes. You can use any of these:

DoCmd.SelectObject acTable, , True
DoCmd.SelectObject acQuery, , True
DoCmd.SelectObject acForm, , True
DoCmd.SelectObject acReport, , True
DoCmd.SelectObject acMacro, , True
DoCmd.SelectObject acModule, , True
DoCmd.SelectObject acModule, , True

... to show the navigation pane, positioned at the group or tab for the
indicated object type. BUT, in Access 2007, you can only do that if there
are objects of that type. This is different from previous versions of
Access, where the tabs existed in the database window regardless of whether
there were any objects of that type in the database.

> I wondering what acCmdWindowUnhide do or is redundant.

I'm not sure.

> The problem of hiding the Nav Pane still hold true even at the user
> machine
> as in Ken's problem. I did not proceed with the test as it will solve the
> problem as in my end. I decide to leave it as it is.

I don't know what is causing the problem for you. As I said, I can't
reproduce it.

AccessVandal via AccessMonster.com

unread,
Jan 15, 2009, 9:51:03 PM1/15/09
to
Dirk,

I think I found the problem. Your first clue was this.
DoCmd.SelectObject acTable, , True

I was wondering, why select a table/form? You got me thinking of retracing
the steps of the original error.

When I first created a new database, by default A2007 create an unnamed table,
close the table without saving. Create a new form – events on buttons or
events on form.

I ran the form without saving. The problem appears. This is not an error as I
soon discovered.

The acCmdWindowHide is the puzzle. What does it do? I my opinion, it does not
truly hide the Navigation Pane at all. What does the Navigation Pane in
Access Option do than?

Back to the form, the selectobject hit me. It dawn to me that acCmdWindowHide
needs an existing object in the Nav Pane! AcCmdWindowHide needs a saved
object in the Nav Pane else the command will fail but not completely.

What do I mean “not completely”?

Well the Nav Pane is still visible. The unsaved form was hidden!

This means that “DoCmd.RunCommand acCmdWindowHide” will hide a window or an
opened window form and as well as the Nav Pane. But if there’s nothing the
Nav Pane, the command will hide the current form window.

In my opinion, the acCmdWindowHide command is best use with precaution.

Dirk Goldgar wrote:
snip..


>I don't know what is causing the problem for you. As I said, I can't
>reproduce it.

--

Dirk Goldgar

unread,
Jan 16, 2009, 2:00:05 PM1/16/09
to
"AccessVandal via AccessMonster.com" <u18947@uwe> wrote in message
news:903ff779fbbe9@uwe...

> Dirk,
>
> I think I found the problem. Your first clue was this.
> DoCmd.SelectObject acTable, , True
>
> I was wondering, why select a table/form? You got me thinking of retracing
> the steps of the original error.
>
> When I first created a new database, by default A2007 create an unnamed
> table,
> close the table without saving. Create a new form – events on buttons or
> events on form.
>
> I ran the form without saving. The problem appears. This is not an error
> as I
> soon discovered.

That explains it. It never even occurred to me that you might not have
saved any objects.

I'm still somewhat confused, though, because if I execute DoCmd.SelectObject
acTable ( or acForm, or whatever) in Access 2007, and there are no objects
of that type, an error is raised. But you didn't report any error. Does
your code have error-handling suppressed by On Error Resume Next?

Hmm, further testing shows something interesting. It's possible to
hide/collapse the Forms group in the nav pane, in which case
"DoCmd.SelectObject acForm" doesn't work and doesn't give an error. I'll
bet that's what happened to you.

> The acCmdWindowHide is the puzzle. What does it do? I my opinion, it does
> not
> truly hide the Navigation Pane at all.

The command does what it says: it hides the active window. If you have
successfully selected the navigation pane, and thus made that the active
window, then the navigation pane is hidden. If you have not selected the
navigation pane, then your form is still the active window, and that form
window will be hidden.

> In my opinion, the acCmdWindowHide command is best use with precaution.

In Access 2007, I'd say you're right. In practice, though, any working
database will have at least one table or one form, and you -- the database
designer -- will know that to be the case. And you'll probably have decided
either not to present the nav pane to your users, in which case you'll have
set that option in your startup settings, or else you'll be using it as part
of your intended user interface, in which case you will not be hiding it.

AccessVandal via AccessMonster.com

unread,
Jan 18, 2009, 8:58:48 PM1/18/09
to
Dirk Goldgar wrote:
>That explains it. It never even occurred to me that you might not have
>saved any objects.
>
>I'm still somewhat confused, though, because if I execute DoCmd.SelectObject
>acTable ( or acForm, or whatever) in Access 2007, and there are no objects
>of that type, an error is raised. But you didn't report any error. Does
>your code have error-handling suppressed by On Error Resume Next?

No, there’s no error handling.

I did not receive any errors with “SelectObject” by unhiding or hiding. I
tried error trapping, but the error number is 0. Except if you use acDefault,
acDiagram, acFunction, acServerView and acStoreProcedure.

>Hmm, further testing shows something interesting. It's possible to
>hide/collapse the Forms group in the nav pane, in which case
>"DoCmd.SelectObject acForm" doesn't work and doesn't give an error. I'll
>bet that's what happened to you.
>

>The command does what it says: it hides the active window. If you have
>successfully selected the navigation pane, and thus made that the active
>window, then the navigation pane is hidden. If you have not selected the
>navigation pane, then your form is still the active window, and that form
>window will be hidden.

The nav pane can still be hidden if there’s no object in it.

By selecting the nav pane horizontal bar and clicking on the ribbon “View
Form”, the OnOpen event correctly hide the nav pane and the form is still
visible. If select the form or cause the form to be in focus, it will not
hide the nav pane but will hide the form.

Thank for pointing that out Dirk.

>In Access 2007, I'd say you're right. In practice, though, any working
>database will have at least one table or one form, and you -- the database
>designer -- will know that to be the case. And you'll probably have decided
>either not to present the nav pane to your users, in which case you'll have
>set that option in your startup settings, or else you'll be using it as part
>of your intended user interface, in which case you will not be hiding it.

Agree.

--
Please Rate the posting if helps you.

Message posted via http://www.accessmonster.com

0 new messages