Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2011-03-02
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2

Accepted Solution

rmonsen earned 2000 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?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


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:

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

609 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