Pacific Database

Home | Contact | FAQs | View Cart

A world of information at your fingertips

How to determine if the Database Container (DBC) Window is visible

    Private Const GWL_STYLE = (-16)
    Private Const WS_VISIBLE = &H10000000
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
		(ByVal hwndParent As Long, ByVal hwndChildAfter As Long, _
		ByVal lpszClass As String, ByVal lpszWindow As String) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
		(ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Public Function IsDBWinVisible() As Boolean
        Dim lngStyle As Long
        Dim hwnd As Long
        
        Const WC_MDICLIENT = "MDIClient"
        Const WC_DBC = "Odb"
        
        hwnd = FindWindowEx(hWndAccessApp, 0, WC_MDICLIENT, vbNullString)
        hwnd = FindWindowEx(hwnd, 0, WC_DBC, vbNullString)
        If (hwnd) Then
            lngStyle = GetWindowLong(hwnd, GWL_STYLE)
            IsDBWinVisible = ((lngStyle And WS_VISIBLE) = WS_VISIBLE)
        End If
    End Function


Show the Database Container (DBC) Window

    Docmd.SelectObject acTable, , True

Hide the Database Container (DBC) Window

    Docmd.SelectObject acTable, , True
    Docmd.RunCommand acCmdWindowHide