Link to home
Start Free TrialLog in
Avatar of pcalabria
pcalabriaFlag for United States of America

asked on

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

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?
ASKER CERTIFIED SOLUTION
Avatar of rmonsen
rmonsen
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of peter57r
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
Avatar of pcalabria

ASKER

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?
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:
http://support.microsoft.com/kb/210590
RM,
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!

Peter,
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
If I use 0, 0 then my form goes into the top left corner of the Access window with no gaps.
Hello,

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?
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.