?
Solved

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

Posted on 2011-03-02
8
Medium Priority
?
205 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
[X]
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
8 Comments
 
LVL 3

Accepted Solution

by:
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.
0
 
LVL 77

Expert Comment

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

Author Comment

by:pcalabria
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?
0
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 
LVL 3

Expert Comment

by:rmonsen
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:
http://support.microsoft.com/kb/210590
0
 

Author Comment

by:pcalabria
ID: 35018218
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
ID: 35018604
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
ID: 35078828
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
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 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