Code to move forms... (1 Viewer)

CedarTree

Registered User.
Local time
Today, 09:29
Joined
Mar 2, 2018
Messages
404
Hello - I have two forms that are open while the user is in the DB. I want to move the one form to the right so that the right edge of the form is within say 10 pixels of the right edge of the Access window. And I want the 2nd form's left edge to line up within say 10 pixels of the left edge of the Access window, regardless of how wide the Nav panel is (so the left side of the form would overlap the Nav panel if it happens to be visible). Suggestions? I figure someone has gone to the trouble of doing the math. THANKS!!!
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:29
Joined
Feb 28, 2001
Messages
27,195
You are looking for the form's properties .WindowHeight, .WindowWidth, .WindowLeft, and .WindowTop

Here is a link to .WindowLeft, but if you look to the left on this particular reference page, you will see the other three items for lookup.


However, this doesn't work in pixels. In order to avoid issues with non-uniform display resolutions i.e. every user potentially has a different screen, Access always works in units of TWIPS, where one TWIP = 1/1440 of an inch. To determine actual resolution,


From there, you can compute twips per pixel (or pixels per twip), which depends only on the dot pitch of your monitor.

 

LarryE

Active member
Local time
Today, 06:29
Joined
Aug 18, 2021
Messages
592
Code:
Private Sub Form_Load()
DoCmd.MoveSize 3500, 1000
Exit Sub
End Sub
This will move the form to the Right 3500 twisps and Down 1000 twisps on your screen when the form loads. Change to meet your needs.
 

Users who are viewing this thread

Top Bottom