I am looking forward to hide the Access background of my project when it's running to give it a more professional look and make it running like a standalone application. I am using Access 2003 and a form is already opening when the project is loaded. I would like to add some code in the Private Sub Form_Open(Cancel As Integer)
of that form to hide the Access background.
2 Answers
The following will work on older versions of Access (tested on Access 2003):
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, use fSetAccessWindow(2)
and fSetAccessWindow(3)
to show minimized/maximized. You can use the Global Const
too. Be careful: Access will be hidden from the taskbar.
If it doesn't work with Access 2010, here is another code that could work: http://www.tek-tips.com/faqs.cfm?fid=2562
The forms must be modal or it won't work. If for some reason you messed up and Access is still running in background but not showing in the taskbar or the task-manager, double click on any Access project again (nothing will happen because Access is still running) and then press ALT+TAB to reach the Access icon (it should magically show up). Nothing happens again because it's hidden, but it's now possible to close it with ALT+F4 if it still has the focus, thus preventing you from rebooting your computer...
In Ms Access 2003 a simple way seem to make the form 1. pop up 2. border style none 3. On form load event run maximise command
Private Sub Form_Load()
DoCmd.Maximize
End Sub