views:

37

answers:

2

I am creating a database application using Access 2003 that will be run as a stand-alone application (i.e. using the Access runtime). I have a main form that opens to a pre-defined location and size and I would like to control where any other forms open.

I would like to open additional forms at the same location and size as the main form. I could use the "autocenter" property but I would like the user to be able to move the form wherever they like and have the new form appear at that location. Only one form will be open at any one time since I close the previous form when opening a new form.

Any suggestions on how to accomplish this with VBA? Thanks.

+1  A: 

Have you considered MoveSize?

http://msdn.microsoft.com/en-us/library/bb238004(office.12).aspx

Remou
+2  A: 

You can read form property values to determine the first form's position and size.

Debug.Print Me.WindowLeft, Me.WindowTop, Me.WindowWidth, Me.WindowHeight

The next form can match those values with the Move method.

Me.Move Left:=0, Top:=0, Width:=400, Height:=300

You would have to decide on a method to pass the values from the first to the second form.

  1. as properties of a custom class
  2. as OpenArgs for the second form
  3. use a table to store the values
HansUp
Worked like a charm. Thank you.
webworm