By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

trying to run DoMenuItem - Database - Window - Hide in autoexec macro w/o success...

P: n/a
MLH
My autoexec macro in an Access 2.0 database has 2 lines.
The first runs DoMenuItem - Database - Window - Hide.
The second lines is Runcode - Initialize(). Initialize is a procedure
in a global module that opens a form. When the form opens,
the database window is still present and visible. I thought the
first line of the macro would run to completion before the
second line started and certainly before any lines in Initialize()
were invoked. But I'm obviously wrong.

Ideas as to why?
Nov 12 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Should work if the database window has focus.
Try a SelectObject (any object) with the InDatabaseWindow set to True, ahead
of the DoMenuItem.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthState.net> wrote in message
news:f4********************************@4ax.com...
My autoexec macro in an Access 2.0 database has 2 lines.
The first runs DoMenuItem - Database - Window - Hide.
The second lines is Runcode - Initialize(). Initialize is a procedure
in a global module that opens a form. When the form opens,
the database window is still present and visible. I thought the
first line of the macro would run to completion before the
second line started and certainly before any lines in Initialize()
were invoked. But I'm obviously wrong.

Ideas as to why?

Nov 12 '05 #2

P: n/a
MLH
I was sure hoping that would work. Unfortunately, it did not
make any difference. I determined the named object was,
in fact, selected in the database window. I tried a couple
of tables and each time, the right one was selected. The
darn database window just won't close when running the
code in initialize. Dunno why?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx
On Thu, 29 Jan 2004 11:09:20 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Should work if the database window has focus.
Try a SelectObject (any object) with the InDatabaseWindow set to True, ahead
of the DoMenuItem.


Nov 12 '05 #3

P: n/a
MLH
The code in Initialize() is not exceptional in any fashion. It checks
to see if tblClient has any records, checks for a file on disk then
looks to see if a particular form exists. Then, it determines screen
resolution and opens frmInitialize. That form is not modal nor popup.
I'm beside myself on this one.

Function Initialize()
10 On Error Resume Next
20 Dim Question As String, MyMsg As String, MyUserName As String,
HorizPixels As Variant
30 CRLF = Chr$(13) & Chr$(10)
40 MyString = GetWinDir() & "\sys1(~)@.tmp"
50 If DCount("[FullName]", "tblClient") = 0 Then
60 If FileExists("MyString") = False Then
70 DoCmd SelectObject A_FORM, "frmInitialize", True
80 If Err = 0 Then
90 FirstTime = True
100 End If
110 End If
120 End If
130 CScreenRes = GetScreenResolution()
131 HorizPixels = Left$(CScreenRes, InStr(1, CScreenRes, "x") - 1)
139 If Val(HorizPixels) < 800 Then
140 MyString = "Resolutions less than 800 x 600 unsupported. "
142 MsgBox MyString, 16, "Cannot Proceed - " & MyApp$
143 DoCmd SetWarnings True
144 DoCmd Quit
145 End If
310 If FirstTime = False Then GoTo SubsequentRuns

FirstRun:
320 DoCmd OpenForm "frmInitialize"
330 If Err = 2102 Then
340 MyMsg = "Program has been corrupted. Contact vendor."
350 MsgBox MyMsg, 48, "Unexpected Error - " & MyApp$
360 End If
370 Exit Function
....
Nov 12 '05 #4

P: n/a
MLH
One more thing, rule out any anomoly you might imagine would
be associated with the unique environment the app is running
in. There are plenty of situations in which hiding the database
window works just fine on this machine. In this particular one, it
does not.
Nov 12 '05 #5

P: n/a
Don't have Acc2 installed any more, but you did remember that the menu items
are zero-based when counting which item it is on the menu?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"MLH" <CR**@NorthState.net> wrote in message
news:eb********************************@4ax.com...
I was sure hoping that would work. Unfortunately, it did not
make any difference. I determined the named object was,
in fact, selected in the database window. I tried a couple
of tables and each time, the right one was selected. The
darn database window just won't close when running the
code in initialize. Dunno why?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx
On Thu, 29 Jan 2004 11:09:20 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Should work if the database window has focus.
Try a SelectObject (any object) with the InDatabaseWindow set to True, aheadof the DoMenuItem.

Nov 12 '05 #6

P: n/a
MLH
Yes. And this code works fine on subsequent runs of the
program. Function Initialize() branches & runs different after
the FIRST time the program is run. On the 2nd and later
launches, the database window hides just fine. The SAME
macro command line works EVERYTIME except for the
FIRST time.

Now, to me, that's odd because the macro command to
hide the DB window is launched first. It is the programmatic
execution on the list. What could possibly matter in the code
that follows? I'm gonna try DoEvents after the DB window
hide & C if that makes a difference.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx
On Fri, 30 Jan 2004 09:32:15 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Don't have Acc2 installed any more, but you did remember that the menu items
are zero-based when counting which item it is on the menu?


Nov 12 '05 #7

P: n/a
MLH
I have tested opening a database with NOTHING but
a 1-line AutoExec macro consisting of DoMenuItem;
Database; Window; Hide. No Tables, Queries, Forms,
Reports or Modules.

That works fine.

So, this tells me that code invoked AFTER the DB
window hide line is preempting the full operation of
the DBWH operation somehow.
Nov 12 '05 #8

P: n/a
MLH
Well, screw me! Line #70 is the problem. I delete frmInitialize on the
first run of the app. In later runs, that form does not exist. Since
it does during the first run, line #70 causes the database window
(hidden on execute of the autoexec macro) to reappear - that's
what's happening. Big Oops! Bit Oops!
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
On Thu, 29 Jan 2004 18:55:58 -0500, MLH <CR**@NorthState.net> wrote:
Function Initialize()
10 On Error Resume Next
20 Dim Question As String, MyMsg As String, MyUserName As String,
HorizPixels As Variant
30 CRLF = Chr$(13) & Chr$(10)
40 MyString = GetWinDir() & "\sys1(~)@.tmp"
50 If DCount("[FullName]", "tblClient") = 0 Then
60 If FileExists("MyString") = False Then
70 DoCmd SelectObject A_FORM, "frmInitialize", True


Nov 12 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.