Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hiding Access main window? 2

Status
Not open for further replies.

mwmarks

IS-IT--Management
Jan 28, 2001
9
0
0
US
I'm new to Access programming and would like to hide the main Access screen from user so they cannot open tables, queries, etc.

Is there a simple way to do this? Thanks.
 
Go to the Tools menu, and look for the Startup option. Uncheck the box that says "Display Database Window".

Of course, this simple approach will only work on users that aren't familiar enough with Access to know to use the F11 key to re-display the database window. Look at the Security FAQs in this forum for a more comprehensive approach to locking out your users.

--Ryan
 
I wish I could remember where I got the original code from so I could give credit where it's due. I simplified it for my needs. It's just a basic function...

Option Compare Database
Option Explicit

Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Public Function fAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
Dim dwReturn As Long

'Set up constant values
Const HIDE = 0
Const SHOWNORMAL = 1
Const SHOWMINIMIZED = 2
Const SHOWMAXIMIZED = 3

'Allows user to Maximize, Minimize, and Hide MSAccess enviornment window
If Procedure = "Hide" Then
dwReturn = ShowWindow(Application.hWndAccessApp, HIDE)
End If
If Procedure = "Maximize" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SHOWMAXIMIZED)
End If
If Procedure = "Minimize" Then
dwReturn = ShowWindow(Application.hWndAccessApp, SHOWMINIMIZED)
End If

'Allows user to toggle whether MSAccess window is visible
If SwitchStatus = True Then
If IsWindowVisible(hWndAccessApp) = 1 Then
dwReturn = ShowWindow(Application.hWndAccessApp, HIDE)
Else
dwReturn = ShowWindow(Application.hWndAccessApp, SHOWMAXIMIZED)
End If
End If

'Returns boolean value if MSAccess window is visible
If StatusCheck = True Then
If IsWindowVisible(hWndAccessApp) = 0 Then
fAccessWindow = False
End If
If IsWindowVisible(hWndAccessApp) = 1 Then
fAccessWindow = True
End If
End If
End Function


 
Thanks Ryan, that was what I needed to get started, and I can research how to do it in code. -Mark
 
I've had this fossil in my Tools module since about 1993..if you'll notice it even refers back to the Access 2.0 menu.. Don't know where I got it, but it works just fine.

Function HideDBWindow() As Integer
With DoCmd
.Echo False
.SelectObject A_MACRO, "AutoExec", True
.DoMenuItem 1, 4, 3, , A_MENU_VER20
.Echo True
End With
End Function

It does depend on the existance of an AutoExec macro, though, as one way to switch focus to the database window before you hide it. You can use any object in your database though, it doesn't matter - just refer to something else in your SelectObject line.



Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
or my site,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top