Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Maximize problem (2000/SP-3)

    Please bear with me as I am a novice with Access. Users started receiving a message that a given form could not be opened. I chased the problem down to the following procedure: <pre>Private Sub Form_Open(Cancel As Integer)
    DoCmd.Maximize
    End Sub
    </pre>


    Speculating that the form had been closed in a state that would not allow the Maximize command, I revised the procedure to: <pre>Private Sub Form_Open(Cancel As Integer)
    DoCmd.Restore
    DoCmd.Maximize
    End Sub
    </pre>


    Reading the help file I understand that I can restore from any window state. Am I safe in this assumption? Should I have revised the code in another manner?

    T.I.A.
    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Maximize problem (2000/SP-3)

    DoCmd.Maximize doesn't cause an error if windows are already maximized, just like DoCmd.Restore doesn't cause an error if windows are already restored. There is no need to restore, then maximize.

    You could see if the problem goes away if you move the line DoCmd.Maximize to the On Activate event of the form. If it persists, there is another problem with your form that has nothing to do with maximizing it.

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Maximize problem (2000/SP-3)

    Hi Hans
    You continue to amaze and confound me.
    Many thanks. The problem did go away by moving the line to the On Activate event.
    Can you offer any explanation as to why?
    Regards
    Don

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Maximize problem (2000/SP-3)

    Normally, it is not a problem, but the On Open event of a form occurs very early. On Activate occurs later in the chain of events, when the form is ready to be displayed.

  5. #5
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Maximize problem (2000/SP-3)

    Thanks Hans

    Though I considered that line of logic; I initially ruled it out, as the failure still occurred when I stepped through the program, My little mind now opines that the opening of the form is interrupted until the On Open event code is completed.

    As always; your depth of knowledge is deeply appreciated.
    Regards
    Don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •