Solved

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

Posted on 2011-03-02
8
193 Views
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?
0
Comment
Question by:pcalabria
  • 4
  • 2
  • 2
8 Comments
 
LVL 3

Accepted Solution

by:
rmonsen earned 500 total points
Comment Utility
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.
0
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
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
0
 

Author Comment

by:pcalabria
Comment Utility
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?
0
 
LVL 3

Expert Comment

by:rmonsen
Comment Utility
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
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:pcalabria
Comment Utility
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
0
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
If I use 0, 0 then my form goes into the top left corner of the Access window with no gaps.
0
 

Author Comment

by:pcalabria
Comment Utility
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?
0
 

Author Comment

by:pcalabria
Comment Utility
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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

9 Experts available now in Live!

Get 1:1 Help Now