Option Compare Database
Option Explicit
Option Base 0
'==============================
' CONSTANTS FOR DBASE WINDOW
'==============================
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
'==========================
' DBASE WINDOW FUNCTIONS
'==========================
Public Declare PtrSafe Function IsWindowVisible Lib "user32" _
(ByVal hWnd As Long) _
As Long
Public Declare PtrSafe Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, _
ByVal nCmdShow As Long) _
As Long
'============================
' FORM MANAGEMENT FUNCTIONS
'============================
Public Function fAccessWindow(Optional Procedure As String, _
Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
'****************************************************************************************
'* Purpose: Controls the behavior and appearance of the Daatabase window *
'* residing on the form, and hence, we reduce the overall size of the FE DB. *
'* Accepts: Procedure - describes the behavior requested *
'* SwitchStatus - (optional) instructs the procedure to switch the current *
'* status of the DB Window *
'* StatusCheck - (optional) allows the procedure to check the current status *
'* of the DB window to determine whether or not to initiate a *
'* change *
'****************************************************************************************
On Error GoTo EH
Dim dwReturn As Long
If Procedure = "Hide" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
End If
If Procedure = "Minimize" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
End If
If Procedure = "Normal" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWNORMAL)
End If
If Procedure = "Show" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
End If
If SwitchStatus = True Then
If IsWindowVisible(hWndAccessApp) = 1 Then
dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
Else
dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
End If
End If
If StatusCheck = True Then
If IsWindowVisible(hWndAccessApp) = 0 Then
fAccessWindow = False
End If
If IsWindowVisible(hWndAccessApp) = 1 Then
fAccessWindow = True
End If
End If
Exit Function
EH:
MsgBox "There was an error resetting the Database Window! " & _
"Please contact your Database Administrator.", vbCritical, "Error!"
Exit Function
End Function
Public Function RestoreForm(FormName As String)
'**********************************************************************************
'* Purpose: Manages the database window, keep the current form on top of others. *
'* Accepts: FormName is the name of the Form which you want to restore *
'* Returns: N/A *
'* Usage: Add "RestoreForm Me.Form.Name" to the OnOpen event of a form *
'**********************************************************************************
On Error GoTo EH
fAccessWindow "Minimize", False, False
DoCmd.SelectObject acForm, FormName
DoCmd.Restore
Exit Function
EH:
MsgBox "There was an error restoring the Form. " & _
"Please contact your Database Administrator.", vbOKOnly, "Error!"
Exit Function
End Function