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.