HelloWorld
HelloWorld

Reputation: 283

Access 2010 Hiding the Access Window

I want to permanently hide the access window. I have a auto exe macro that hides the window initially but if the user ever clicks my database's icon on the task bar if appears behind my forms and is just rather annoying. I was wondering if there was a way to keep it down without having to copy past a hide window macro every where

Upvotes: 0

Views: 7421

Answers (1)

dan
dan

Reputation: 3519

The following will work on older versions of access (source: http://www.vbaexpress.com/kb/getarticle.php?kb_id=74):

Option Compare Database 
Option Explicit 

Global Const SW_HIDE = 0 
Global Const SW_SHOWNORMAL = 1 
Global Const SW_SHOWMINIMIZED = 2 
Global Const SW_SHOWMAXIMIZED = 3 

Private Declare Function apiShowWindow Lib "user32" _ 
Alias "ShowWindow" (ByVal hWnd As Long, _ 
ByVal nCmdShow As Long) As Long 

Function fSetAccessWindow(nCmdShow As Long) 

    Dim loX As Long 
    Dim loForm As Form 
    On Error Resume Next 
    Set loForm = Screen.ActiveForm 

    If Err <> 0 Then 
        loX = apiShowWindow(hWndAccessApp, nCmdShow) 
        Err.Clear 
    End If 

    If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then 
        MsgBox "Cannot minimize Access with " _ 
        & (loForm.Caption + " ") _ 
        & "form on screen" 
    ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then 
        MsgBox "Cannot hide Access with " _ 
        & (loForm.Caption + " ") _ 
        & "form on screen" 
    Else 
        loX = apiShowWindow(hWndAccessApp, nCmdShow) 
    End If 
    fSetAccessWindow = (loX <> 0) 
End Function 

Just call fSetAccessWindow(0) to hide and fSetAccessWindow(1) to show. Alternatively, you could use fSetAccessWindow(2) and fSetAccessWindow(3) to show minimized/maximized. The application will be hidden from the taskbar too, preventing users from clicking it.

If it doesn't work with Access 2010, you could also try this: http://www.tek-tips.com/faqs.cfm?fid=2562

Upvotes: 1

Related Questions