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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MLH

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

    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?
  • Allen Browne

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

    Should work if the database window has focus.
    Try a SelectObject (any object) with the InDatabaseWindo w 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" <CRCI@NorthStat e.net> wrote in message
    news:f4fg109pig qaqj3nueeabqkar 15tc28kkn@4ax.c om...[color=blue]
    > 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?[/color]


    Comment

    • MLH

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

      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?

      xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxx


      On Thu, 29 Jan 2004 11:09:20 +0800, "Allen Browne"
      <AllenBrowne@Se eSig.Invalid> wrote:
      [color=blue]
      >Should work if the database window has focus.
      >Try a SelectObject (any object) with the InDatabaseWindo w set to True, ahead
      >of the DoMenuItem.[/color]

      Comment

      • MLH

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

        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("MyS tring") = 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 = GetScreenResolu tion()
        131 HorizPixels = Left$(CScreenRe s, InStr(1, CScreenRes, "x") - 1)
        139 If Val(HorizPixels ) < 800 Then
        140 MyString = "Resolution s 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 "frmInitial ize"
        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
        ....

        Comment

        • MLH

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

          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.

          Comment

          • Allen Browne

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

            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" <CRCI@NorthStat e.net> wrote in message
            news:eb6j10102u k7e50gr6aaupg5t pdktta0r8@4ax.c om...[color=blue]
            > 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?
            >
            > xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxx
            >
            >
            > On Thu, 29 Jan 2004 11:09:20 +0800, "Allen Browne"
            > <AllenBrowne@Se eSig.Invalid> wrote:
            >[color=green]
            > >Should work if the database window has focus.
            > >Try a SelectObject (any object) with the InDatabaseWindo w set to True,[/color][/color]
            ahead[color=blue][color=green]
            > >of the DoMenuItem.[/color]
            >[/color]


            Comment

            • MLH

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

              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.

              xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxx


              On Fri, 30 Jan 2004 09:32:15 +0800, "Allen Browne"
              <AllenBrowne@Se eSig.Invalid> wrote:
              [color=blue]
              >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?[/color]

              Comment

              • MLH

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

                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.

                Comment

                • MLH

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

                  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!
                  xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxx


                  On Thu, 29 Jan 2004 18:55:58 -0500, MLH <CRCI@NorthStat e.net> wrote:
                  [color=blue]
                  >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("MyS tring") = False Then
                  >70 DoCmd SelectObject A_FORM, "frmInitialize" , True[/color]

                  Comment

                  Working...