acCmdWindowHide has no effect

A

AccessVandal via AccessMonster.com

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..
 
D

Dirk Goldgar

AccessVandal via AccessMonster.com said:
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.
 
A

AccessVandal via AccessMonster.com

Dirk said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top