Move to command

  • Thread starter Thread starter peljo via AccessMonster.com
  • Start date Start date
P

peljo via AccessMonster.com

On opening the form, i want to give a command with Move To command to move to
the right upper corner. Is there any such command ?
 
In the Open event, write the following code:

Private Sub Form_Open(Cancel As Integer)
DoCmd.MoveSize 0, 0
End Sub
 
peljo via AccessMonster.com said:
On opening the form, i want to give a command with Move To command to move
to
the right upper corner. Is there any such command ?

Paste this code into the declarations section of your form's module:

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hWnd As Long, lpRect As Rect) As Long
Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Then paste this in as your Form_Open event procedure:

Private Sub Form_Open(Cancel As Integer)
Dim r As Rect, w As Long
GetWindowRect GetDesktopWindow(), r
w = (r.Right - r.Left) * 15
DoCmd.MoveSize w - Me.WindowWidth, 0
End Sub


Now your form should open where you want it.
 
Back
Top