Private Sub Form_Open(Cancel As Integer)
With DoCmd
.SelectObject acForm, "myformname"
.MoveSize 0, 0
End With
Me.Width = 6.5 * 1440 '6.5 inches wide for the window
Me.InsideHeight = 2.125 * 1440 '2.125 inches high for the window working area
Me.InsideWidth = 6.25 * 1440 '6.25 inches wide for the window working area
end sub
Option Compare Database
Option Explicit
Public Declare Function LoadLibraryEx Lib "kernel32.dll" Alias "LoadLibraryExA" (ByVal lpFileName As String, ByVal hFile As Long, ByVal dwFlags As Long) As Long
Public Declare Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Public Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Public Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As Long) As Boolean
Public Declare Function EnumDisplayMonitors Lib "User32.dll" (ByVal hdc As Long, ByRef lprcClip As Any, ByVal lpfnEnum As Long, ByVal dwData As Long) As Boolean
Public Declare Function GetMonitorInfo Lib "User32.dll" Alias "GetMonitorInfoA" (ByVal hMonitor As Long, ByRef lpmi As MONITORINFOEX) As Boolean
Public Declare Function MonitorFromWindow Lib "User32.dll" (ByVal hWnd As Long, ByVal dwFlags As Long) As Long
Public Const CCHDEVICENAME = 32
Public Const MONITORINFOF_PRIMARY = &H1
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Type MONITORINFOEX
cbSize As Long
rcMonitor As RECT
rcWork As RECT
dwFlags As Long
szDevice As String * CCHDEVICENAME
End Type
Dim MonitorId() As String
Private Function PrintMonitorInfo(ForMonitorID As String) As Long
Dim MONITORINFOEX As MONITORINFOEX
Dim info As String
MONITORINFOEX.cbSize = Len(MONITORINFOEX)
If GetMonitorInfo(CLng(ForMonitorID), MONITORINFOEX) = False Then Exit Function 'Failed "GetMonitorInfo"
With MONITORINFOEX
With .rcWork
PrintMonitorInfo = .Left
End With
End With
End Function
Public Function MonitorEnumProc(ByVal hMonitor As Long, ByVal hdcMonitor As Long, ByRef lprcMonitor As RECT, ByVal dwData As Long) As Boolean
Dim ub As Integer
ub = 0
On Error Resume Next
ub = UBound(MonitorId)
On Error GoTo 0
ReDim Preserve MonitorId(ub + 1)
MonitorId(UBound(MonitorId)) = CStr(hMonitor)
MonitorEnumProc = 1
End Function
Public Function AppLeft() As Long
Dim hMonitor As String
Dim i As Integer
hMonitor = MonitorFromWindow(Application.hWndAccessApp, &H0&)
AppLeft = PrintMonitorInfo(hMonitor)
End Function
Private Sub Form_Open(Cancel As Integer)
Dim LeftPosition As Single
LeftPosition = AppLeft() / 96 * 1440
With DoCmd
.SelectObject acForm, "myformname"
.MoveSize LeftPosition, 0
End With
Me.Width = 6.5 * 1440 '6.5 inches wide for the window
Me.InsideHeight = 2.125 * 1440 '2.125 inches high for the window working area
Me.InsideWidth = 6.25 * 1440 '6.25 inches wide for the window working area
end sub
Private Sub Form_Open(Cancel As Integer)
With Me
.Move 0, 0
.Width = 6.5 * 1440 '6.5 inches wide for the window
.InsideHeight = 2.125 * 1440 '2.125 inches high for the window working area
.InsideWidth = 6.25 * 1440 '6.25 inches wide for the window working area
End with
end sub
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)