Results 1 to 5 of 5

Thread: Maximise a form

  1. #1
    2 Star Lounger
    Join Date
    Mar 2004
    Posts
    185
    Thanks
    37
    Thanked 1 Time in 1 Post
    When my Access app starts I wish to automatically maximise the initial form. I tried code like -

    Const SW_SHOWMAXIMIZED = 3
    Dim intWindowHandle As Long
    Dim Maxit%
    intWindowHandle = Screen.ActiveForm.Hwnd
    Maxit% = ShowWindow(intWindowHandle, SW_SHOWMAXIMIZED)

    Basically this works BUT.. The problem is that whichever form event I use to trigger a function containing this code the line that gets the window handle always fails, because the forms window has not yet opened. I have tried just about every event there is with no success. I did find the help file that lists the order of these events, but that did not help.

    So my basic question is, is there a way of maximising an apps first window?
    My sub question is, is there any list that defines all the events available in event properties?

    I am running Access 2007 on XP SP3

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    You can maximize any form by putting
    Docmd.Maximize
    in the form's OnActivate event.

    I just did a search in VBA Help for Form Object Events, and it produced a screen listing 50 events, each item a link to help about that event.
    Regards
    John



  3. #3
    2 Star Lounger
    Join Date
    Mar 2004
    Posts
    185
    Thanks
    37
    Thanked 1 Time in 1 Post
    John,
    Thanks for reply - your code worked fine - I had tried the Docmd.Maximize thing before unsuccessfully - I suspect I associated it with the wrong event.

    The help also worked as you described - I had just not tried that particular combination of words to do the search on - and it also only worked if I had "Content on this computor / Developer Reference" set - "All Access" produced a short list nothing like what I wanted.

    However even then this does not seem to be a complete list - for example I can't find "OnActive" in it - or in the Contents - which I can be more sure of since this is listed alphabetically. More research suggests that MS consider onactive to be a property rather than an event - it is listed as such in the contents under Forms/Properties. I suppose the fact of the property becoming true is also considered an event? Of course I recognise that the forms property sheet lists On Active under the event tab, so when is a property an event?

    Regards,
    Peter

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    I don't think you will find an exhaustive list of events for all of Access, as the events available for a specific object are unique to that object. For example, it doesn't make sense to have a close event on a label, but does on a form. However if you open a form or report and look at the properties for it or any of the controls on it, you can see the events that apply to that object. And in most versions of Access, if you press F1 you will get the help associated with that event. Note however that the quality of the help varies from version to version.
    Wendell

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    I agree that Help in relation to Activate or OnActivate is confusing.
    I regard an event as something that happens. So when we write an event procedure, we are saying I want this code to run whenever this happens.
    So when a form is activated, any code in the onactivate event will run.
    Regards
    John



Posting Permissions

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