Okay I get that. The suggestion was if Vba7 then... but it said Vba7 was undefined - so I left off the vba7 if then for now.
Still - if the form is off the main monitor and then the DB is started on single monitor unit - you can not close the form (I open to a pop up modal form)
Here is what I have now:
Code:
Option Compare Database
Option Explicit
Public Declare PtrSafe Function LoadLibraryEx Lib "kernel32.dll" Alias "LoadLibraryExA" (ByVal lpFileName As String, ByVal hFile As LongLong, ByVal dwFlags As LongLong) As LongLong
Public Declare PtrSafe Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As LongLong, ByVal lpProcName As String) As LongLong
Public Declare PtrSafe Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As LongLong
Public Declare PtrSafe Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As LongLong) As Boolean
Public Declare PtrSafe Function EnumDisplayMonitors Lib "User32.dll" (ByVal hdc As LongLong, ByRef lprcClip As Any, ByVal lpfnEnum As LongLong, ByVal dwData As LongLong) As Boolean
Public Declare PtrSafe Function GetMonitorInfo Lib "User32.dll" Alias "GetMonitorInfoA" (ByVal hMonitor As LongLong, ByRef lpmi As MONITORINFOEX) As Boolean
Public Declare PtrSafe Function MonitorFromWindow Lib "User32.dll" (ByVal hWnd As LongLong, ByVal dwFlags As LongLong) As LongLong
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