No matter what code examples I use from this forum, I cannot get a form to stay on top within the Access .MDB (I am not running it from an .MDE). Here is the code that I am using. Does anyone see anything wrong?
In a module:
In the form:
In a module:
Code:
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
' Topmost window
Private Const HWND_TOP = 0
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Public Sub OnTop(ByVal lhWnd As Long)
SetWindowPos lhWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
Public Sub NotOnTop(ByVal lhWnd As Long)
SetWindowPos lhWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
In the form:
Code:
Private Sub Form_Load()
DoCmd.Restore
Call OnTop(Me.hWnd)
End Sub