I have an issue with my database. I want to run it in a window as an ap without all of the Access interface. I've been successful in this by setting the forms to popup and modal and using the code below on the startup form. I got the code off another forum and it works really well, that is until you click the Access icon on the Windows taskbar at which point the Access interface becomes unhidden. I have tried attaching the code to other events on the form such as On Activate and On Load etc but can't find a way of stopping the Access interface from reappearing. It is inevitable that users will at some point click the taskbar icon, I did it during testing when I opened another window and then went back to my database. I'd welcome any suggestions on how to overcome this problem.
This is the code I call on the On Open event of my startup form:
Option Explicit
'This function switches the display mode of the Access design database, call function and pass in appropriate constant, code off forum
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