Open a form at a specific location on the screen

R

Robert_L_Ross

Can someone tell me how to force a form to open at a specific location on the
screen?

As an example, I have my switchboard open at the center of the screen (I
chose center to account for different screen resolutions). I have another
form that opens and shows the WindowTop and WindowLeft values for the main
switchboard. I'd like to add some code to another form
(SwitchboardReportMenu) to force it to open at the exact same location as the
main Switchboard. See, the SwitchboardReportMenu form is the exact same size
and looks the same, but has date values that are used for queries. If I add
the date fields to the main Switchboard, I'd have to use all kinds of macros
to hide them when not needed (not to mention maintenance - fields on top of
fields in that little switchboard and having to hide and unhide fields at
every click).

Anyone know how to add code to the On Open event or something similar to
force the form to open at the same location that the main Switchboard opens?

THX!
 
F

FrankTimJr

In the OnLoad event, use DoCmd.MoveSize (
, [Down])

You can specifiy where on the screen the form will show up from the left and
top of the window in inches, like

DoCmd.MoveSize 2.5, 2.5​
 
F

fredg

In the OnLoad event, use DoCmd.MoveSize (
, [Down])

You can specifiy where on the screen the form will show up from the left and
top of the window in inches, like

DoCmd.MoveSize 2.5, 2.5

*** snipped ***

Note that the measurements must be in Twips (1440 per inch), so the
above code should be written like this:

DoCmd.MoveSize 2.5*1440, 2.5*1440​
 
R

Robert_L_Ross

Frank,

I ended up finding the Move command, and it's actually in pixels for that
command. Here is the line I ended up with:
Form.Move Forms!Switchboard.WindowLeft, Forms!Switchboard.WindowTop,
Forms!Switchboard.WindowWidth, Forms!Switchboard.WindowHeight

By using the value directly from the command I was able eliminate the need
for an intermediary form to hold the location of my original menu.

My only remaining problem is that with some forms (Switchboard) an extra
toolbar appears. When I open the new form, that toolbar disappears, so the
form is artificially higher by the same amount as a toolbar is. I've put a
temporary fix of just rearranging the toolbars, but in the end I'm going to
have to remove all toolbars and only allow one that I specify (a little
nervous as I don't know a lot about toolbars).

THX for the response though!

FrankTimJr said:
In the OnLoad event, use DoCmd.MoveSize (
, [Down])

You can specifiy where on the screen the form will show up from the left and
top of the window in inches, like

DoCmd.MoveSize 2.5, 2.5

Robert_L_Ross said:
Can someone tell me how to force a form to open at a specific location on the
screen?

As an example, I have my switchboard open at the center of the screen (I
chose center to account for different screen resolutions). I have another
form that opens and shows the WindowTop and WindowLeft values for the main
switchboard. I'd like to add some code to another form
(SwitchboardReportMenu) to force it to open at the exact same location as the
main Switchboard. See, the SwitchboardReportMenu form is the exact same size
and looks the same, but has date values that are used for queries. If I add
the date fields to the main Switchboard, I'd have to use all kinds of macros
to hide them when not needed (not to mention maintenance - fields on top of
fields in that little switchboard and having to hide and unhide fields at
every click).

Anyone know how to add code to the On Open event or something similar to
force the form to open at the same location that the main Switchboard opens?

THX!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top