Search code examples
screencenterfullscreenelement

Access vba center form elements on full screen


I'm working on a application in Access. What I am trying to do is to make my screen go full screen (docmd.maximaze) That is no problem,

But what I want, is that all my elements in the screen go to the center, you guys got any idea how to fox this?


Solution

  • You would need to determine the size of the form/window & the monitor resolution on the window change/resize/maximize event, and then with that info, you can do one of the following things:

    • Each control will need a starting location and a maximized location on the form. On the window change event or user defined function in a code module, loop through the controls and rearrange them to be in the proper locations on the form.

    • Create 2 versions of the same form based on different resolutions, then in a code module decide which to display. Not elegant by any means, and creates more forms to maintain, but it works, especially in environments where the monitor sizes are not standardized, as well as for the users with vision issues that use very low resolutions.

    • The way I like to get around these issues is using subforms programatically controlled by a main form, basically an MDI-type app, so you can easily persist the data & 'session state' so to speak between form loads.

    • Make the app window modal, non resizable, no min/max buttons, close button exits the form or the app. Then no more worries about the form being resized/displayed improperly.