Form position on screen

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Is there a way to force a form to appear at a particular spot on the screen.
I have a small pop up form to display details from a list box that I would
like to place on the screen near the list box that was clicked.
 
Is there a particular event in which to set these properties? When I try to
assign a value it tells me that Form.Left and Form.Right properties do not
exist. I am using Access 2000, are these properties in a later version?
 
Is there a way to force a form to appear at a particular spot on the screen.
I have a small pop up form to display details from a list box that I would
like to place on the screen near the list box that was clicked.

Look up the Move size method in VBA help.

DoCmd.MoveSize 1440,2880

will position a form 1 inch from the left and 2 inches from the top of
the window. All measurements are in Twips ... 1440 = 1 inch.

To open a form and position it near a control on a form that has just
been double-clicked:

First, add a new Sub Procedure to the Form's code sheet.

Public Sub OpenSmall(Position As String)
DoCmd.OpenForm "frmSmall", , , , , acDialog, Position
End Sub
====
Code the control's Double Click event:

Private Sub ControlName_DblClick(Cancel As Integer)
OpenSmall Me.ActiveControl.Left & "," & Me.ActiveControl.Top
End Sub
=========

Code the newly opened form's Load event:

Private Sub Form_Load()
DoCmd.MoveSize Left(Me.OpenArgs, InStr(Me.OpenArgs, ",") - 1),
Mid(Me.OpenArgs, InStr(Me.OpenArgs, ",") + 1)

End Sub
=========

Double-clicking the control will open a form just above it.
There is no need to set the second form's PopUp and/or Modal property
to Yes, as acDialog will automatically open it modal.
 
Back
Top