Getting pop-up form to center on monitor

I'm somewhat confused by your lengthy (but incomplete) reply so apologies if I'm missing the point here

Form positions and sizes are measured in twips and cannot currently exceed the integer limit of 32767 (approx. 22.75 inches)
Your code will give unpredictable results if you try to exceed that

I have various articles that may be helpful including:

I suggest you limit the height of continuous forms to be slightly less than the monitor height
I prefer the code in Form 3 but that won't solve your issue.
 
Apologies, I gave up on that fragment by the look of it but didn't notice it was still hiding at the end there! Thanks for taking the time anyway.

The Twips limit makes sense for the issues I'm seeing, but how does Access handle a 3 monitor setup that's wider than 22 inches? Is that why I'm seeing negative twips returned by me.Windowleft? I'm not explicitly trying to exceed 22 inches, I'm just trying to get forms to appear in relatively sensible places, e.g. if a user opens a large form and drags it to a second window, then clicks a button that causes a second small popup form to appear I'd like it to be somewhat near where they're currently working, rather than center it on a different monitor miles away,

I had wondered about trying to grab the mouse position and putting the form there but it comes back to the "how do I handle the negative twips" issue?
 
There's an alternative method which may prove useful "Sticky Forms" forms that stay where they are put ....

 
Last edited:
Having read into this a bit more I'm concerned the large 2 and 3 screen setups will cause issues with the TWIPS limits so I'm not sure I want to go the sticky forms route
 
I already knew it works. Just illustrating that it's a lot easier to hardcode the positioning versus using generic functions.
So why ask the question if you already know it works?
It has also been explained in another thread why hardcoding the values is often not the best solution
 
Agreed that hardcoding can at times be appropriate but that doesn't explain why you asked a question that you say you already knew the answer to
 
Too late as there have been several replies.
 
I haven't read every post fully, but isn't a "popup" form automatically centred?

I actually don't tend to use popup forms. I use standard forms, and where I want popup functionality I wait for the form to close before continuing (ie wait for the process to realise that the popup from is no longer open) . This allows other features of the database to be used while waiting for the user to close the "popup". I also store the size and position of each form for the next time it's used.
 
Video about autocentre. It seems to remember where the form was when you saved the design, I think. (Edit. Apparently it did misbehave but fixed now. See the video below)

 
Last edited:
On my website I have an explanation of how to build a sticky form basically a form pops up and it always covers up something you want to look at! You move it over and next time you load up the damned thing is back where it was covering up what you want to see! Is possible to make what I call a sticky form is when you've moved it it stays there see my website for links to some excellent instructions on how to do this yourself:-

 
Forms will always open where they were last saved UNLESS the AutoCenter property is set to Yes (or code is used to centre it in Form_Load event.)
This is true for both standard forms and popups.
 
Richard Rost said in the video MS fixed auto center couple years ago.
Yes, I looked at the start, and posted the link as it seemed useful but then realised it was fixed now. I just didn't edit my post. (Edit. I have edited it now)

It looks to me as if MS centered the bottom of the popup in the centre of the screen, as Richard was drawing those little rulers.
 
It looks to me as if MS centered the bottom of the popup in the centre of the screen, as Richard was drawing those little rulers.
I haven't watched Richard's video but that point isn't correct

If AutoCenter is set to Yes then
a) a standard form is centred horizontally in the database window
b) a popup form is centred horizontally on the monitor

BUT
c) for both types of form the form is placed with the top about 1/3 of the way down the application window / monitor. This is true no matter whether the form height is small / large

I'm using 365 version 2508 but AFAIAA, there has been no change to the position of an autocentred form in many years
 
I haven't watched Richard's video but that point isn't correct

If AutoCenter is set to Yes then
a) a standard form is centred horizontally in the database window
b) a popup form is centred horizontally on the monitor

BUT
c) for both types of form the form is placed with the top about 1/3 of the way down the application window / monitor. This is true no matter whether the form height is small / large

I'm using 365 version 2508 but AFAIAA, there has been no change to the position of an autocentred form in many years

Richard mentioned this in his video. Just as he clicked off it in the video, I noted that looked like the bottom of the popup form was on the centre, but I can now see that isn't the case. There is clearly some formula to work out the top, but it's not easy to know how Access does it.
 
It is precisely because Access doesn't centre forms vertically that I have code to do so more accurately.
Some of it is mine but I also have code by other developers. See my article:

Which works best? It depends!
 

Users who are viewing this thread

Back
Top Bottom