David said:
Hello
Is there any way to get the screen position of a control in order to open
a
user form close to it?
I haven't tested it thoroughly, and not all the methods and properties used
exist in versions of Access before Access 2003 (or maybe 2002), but code
along these lines seems to work:
'----- start of example code -----
Dim ctlTarget As Access.Control
Dim lngBorderHoriz As Long
Dim lngBorderVert As Long
Set ctlTarget = Me.txtMyTextbox ' Open beside this control
DoCmd.OpenForm "FormToOpen"
lngBorderHoriz = (Me.WindowWidth - Me.InsideWidth) / 2
lngBorderVert = (Me.WindowHeight - Me.InsideHeight) / 2
With Forms("FormToOpen")
.Move _
(Me.WindowLeft - .WindowWidth) + lngBorderHoriz +
ctlTarget.Left, _
Me.WindowTop + lngBorderVert + ctlTarget.Top
End With
'----- end of example code -----