It can be done with API calls. This code is from API-Guide 3.7 with a couple
of Debug.Prints added to demonstrate Left and Top.
Private Const SW_MINIMIZE = 6
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WindowPlacement
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long,
lpPoint As POINTAPI) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As
Long, lpwndpl As WindowPlacement) As Long
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As
Long, lpwndpl As WindowPlacement) As Long
Dim Rectan As RECT
Public Sub WindowPlacement(strFormName As String)
'Tip submitted by pyp99 (
[email protected])
Dim WinEst As WindowPlacement
Dim rtn As Long
WinEst.Length = Len(WinEst)
'get the current window placement
rtn = GetWindowPlacement(Forms(strFormName).hwnd, WinEst)
Rectan = WinEst.rcNormalPosition
Debug.Print Rectan.Left
Debug.Print Rectan.Top
End Sub
Going back to Arvin's suggestion, you can set the form's Moveable property
to False to keep the user from moving the form. Even with this set at False,
you can still move the form in code using the Move method. It will ignore
the Moveable setting.
--
Wayne Morgan
MS Access MVP
Jim Bunton said:
I would like to find a form's position
either
Within the Access window
or
on the screen
[so that I can position other forms relative to it when I open them]
? any offers please