Is there a way to programatically fix where on a page a MS Access opens?

Posted on 2011-03-02
Last Modified: 2013-02-19
Hello Experts!

I have a MS Access application that opens a number of forms that the user will want to view all at the same time.

The application is designed to run on a computer with a 1280 x 1024 monitor.

The forms have been designed to fit on the page in a maner that does not cause overlap.  For example, the main screen displays two forms, each approximately 640 x 1024, and these forms display side by side.

Currently, in order to make things fit I must display the form in design view to propertly size and position it.  This is problematic because if its off just a bit, it causes the slider bars to appear which cover up parts of the form, or for the form to go off screen.  

The other problem caused by manually sizing and positioning is that every time I edit the form I wind up moving it and then need to do so again.

What I would like is to programatically set the size in some way, to 640 x1024 and have the first form open with its left top corner at pixel 1,1 and the second form open at pixel 641,1.

Can you help?
Question by:pcalabria
  • 4
  • 2
  • 2

Accepted Solution

rmonsen earned 500 total points
ID: 35015898
Use the Move method of the form object to do this. If you place the call in the OnOpen event, the form will move to the desired position upon opening. For example:

Private Sub Form_Open(Cancel As Integer)
    Me.Move 5000, 5000, 8000, 8000
End Sub

Open in new window

The first two arguments are the position, the last two are the size of the form. The last three arguments are optional, so you do not need to input a size if you don't want.

Note that these sizes are in twips (the standard measuring unit used by Access), and not pixels, so you will need to experiment with larger values. Since both position and and size are expressed int he same units, it should be easit to calculate however.

Note that instead of having a lot of seperate forms appearing on screen, if it is always the same combinations, it might be better to just create a large form and include allt he individual forms as subforms on this form.
LVL 77

Expert Comment

ID: 35015916
You can use a
docmd.MoveSize left,top,width,height
in the form open event procedure to position and size a form within the Access window.
The measurements are in twips - there are 1440 twips per inch

Author Comment

ID: 35016183
I seem to remember reading about twips before, but doesn't this require all monitors to be the same size in order to work properly?

While most of our workstation monitors are 17" (diagonal, I'm sure) using a standard 4x3 display (not wide screen), we also use 15" laptops.

It seems that using a measurement based upon monitor size would cause things to get out of alignment on one system or the other.  

Can you think of a way to solve this problem?

Expert Comment

ID: 35016324
There is a method here to convert twips to pixels using the capabilities of the current device. Just reverse the final calculation in the function to go the other way (pixel -> twips) since this is what you need:
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.


Author Comment

ID: 35018218
I receive a "Method or data member not found" error when I try to use me.move

I've even pasted your code in my form onopen event and get the same error.

The conversion routine looks promising but honestly, I'll need to study it for a while more to see if I can understand how it works before I attempt reversing the formula!

I can't seem to get the movesize command to move the form all the way to the top edge of the open window.  It will only move it to within about 3/8" of the top.  

I created a new form and put the below code in the onopen event to see if I can propertly move around the form.  If you'd like to give it a try to see what happens on your machine, the code is below.

Dim intLeft As Long
Dim intTop As Long
intLeft = InputBox("Left Pos")
intTop = InputBox("top pos")
DoCmd.MoveSize intLeft, intTop
LVL 77

Expert Comment

ID: 35018604
If I use 0, 0 then my form goes into the top left corner of the Access window with no gaps.

Author Comment

ID: 35078828

Sorry to take so long to get back to you, its been a busy week.

This issue that I am having seems to do with toolbars.  In normal design view, I use the Form Design, Formatting, and a Custom toolbar.

When I open the form, it does move to the top left corner with 0,0 used, however, one of my toolbars then disappears (perhaps because I am no longer in design mode?) leaving a space, the size of the toolbar between the top of the form and the top of the window.

I suspect if I can programatically make the toolbar's hide before the movesize command is excuted, it will work correctly.
Any ideas?

Author Comment

ID: 35318333
This is still an open action item for me, however, I'd like an opinion on whether this approach will work when users of the application use different size monitors.

Some, for example, use 40 inch flat screen monitors, while others use more conventional 15 inch 4x3 format LCD monitors, and others use a variety of laptop computers.

Is any approach the uses twips going to work on all the machines?

Everyone uses 1280x1024 resolution, except the widescreen users who use 1680 x 1050.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now