I have a simple database that around 20 people are going to be entering data into. I'm trying to simplify this as much as possible to reduce the amount of problems they might run into. I have a switchboard form that gives the users everything they need to interact with (four forms and three reports) that I run on startup. I want to just show this switchboard form and nothing else to the users. I found a really nice piece of code that accomplishes this which can be seen here and copied below:
Code:
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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)
'Usage Examples
'Maximize window:
' ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
' ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
' ?fSetAccessWindow(SW_HIDE)
'Normal window:
' ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then 'no Activeform
If nCmdShow = SW_HIDE Then
MsgBox "Cannot hide Access unless " _
& "a form is on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
Else
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
End If
fSetAccessWindow = (loX <> 0)
End Function
'************ Code End **********
I have this pasted into a module, and on startup I call fSetAccessWindow(SW_HIDE). The only problem that I have run into is I'm not able to open any reports from my switchboard. Forms work perfectly, but reports don't open at all. Access ends up freezing up and I have to go into the task manager and end the program. I've tried numerous work arounds included using the fSetAccessWindow(SW_SHOWMAXIMIZED) function call when opening any report, but that doesn't work either as access gets really weird when closing the report. I also have all my reports set as popup and modal.
Does anybody know how to modify this piece of code so I could have the same functionality with reports as I do with forms? Or does anybody know of another solution? This isn't really a game changer for my database as I have the database closing once the startup form (which is popup and module) closes meaning the users can already only interact with the switchboard form, but being able to hide the stuff would make it even cleaner.