db Window wont hide...?

Kevin_S

Registered User.
Local time
Today, 11:29
Joined
Apr 3, 2002
Messages
635
Hi everyone,

I have a question about hiding the db window/menu. I want to hide this window so that the users can't get to the database tables/forms/queries/repots/etc... and mess around with the db behind the control of the forms so I went into Tools -- StartUp -- and unchecked the box for Display database Window. I assumed this would take care of the window. Now when I start up the database the db window is hidden (as it should be) when the splash form loads but as soon as the switchboard opens the db window becomes available in the taskbar at the bottom of the screen. The window is not opened and displayed, however, all one has to do is click the button for it in the taskbar and there it is!!! This also happen if a user minimizes MS Access and the maximizes access - it is then displayed...?

Does anyone know why this is happening and/or know of a way to stop this...?

thanks to all,
Kev
 
I forget where I read this (in the Access help perhaps), but the visibility of the database window depends on how you open the database. If you open it through your "most recently used" list or via a shortcut to the database mdb file, it won't properly hide the window.
 
Have you tried distributing and MDE?

Did you Disable the Short Cut Keys?
 
dcx693 - I have tried to open the db through a shortcut (This is how the end user will open the db) & through just double-clicking on the mdb file itself - both with the same result. I looked in the help files but I didn't come across that article... any ideas on where I can find that reference?

Travis - In the startup menu I also disabled the allow shortcut keys checkbox and my forms have 'allow shortcut menu' set to No. I created an mde but I get the same result... the db opens -- the db window is hidden but available in the taskbar...? The only difference is that with the mde the user can't enter into design view on objects - but they can still get to everything...?

Any other thoughts...?

Could it have to do with code running behind the forms? Surely you can have code running and the db window hidden...?

thanks for the continued help!
Kev
 
dcx693 - the first article you posted had the solution - I apprciate the help! :D

for those reading this post that are interested: this is a common "bug" in MS Access XP that can be resolved either by downloading the most recent XP service pack (which I was not able to do because I am at work) OR the work-around for this is to open the db and go to Tools -- Options -- go to the view tab and uncheck the box marked 'Windows in taskbar'.

thanks for the help!
Kevin
 
Hide the DB Window

If you create a module in Access and dump this code in it...

Code:
Option Compare Database
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

'--------------------------------------------------------------
' Copyright ©1996-2002 VBnet, Randy Birch, All Rights Reserved.
' Terms of use [url]http://www.mvps.org/vbnet/terms/pages/terms.htm[/url]
'--------------------------------------------------------------

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

Public Const ERROR_SUCCESS As Long = 0
Public Const CSIDL_DESKTOP As Long = &H0
Public Const CSIDL_PROGRAMS As Long = &H2
Public Const CSIDL_STARTMENU As Long = &HB
Public Const CSIDL_DESKTOPDIRECTORY As Long = &H10

Public Const FO_COPY As Long = &H2
Public Const FOF_SILENT As Long = &H4
Public Const FOF_RENAMEONCOLLISION As Long = &H8
Public Const FOF_NOCONFIRMATION As Long = &H10

Public Type SHFILEOPSTRUCT
  hwnd      As Long
  wFunc      As Long
  pFrom      As String
  pTo        As String
  fFlags     As Integer
  fAborted   As Boolean
  hNameMaps  As Long
  sProgress  As String
End Type

Public Declare Function SHFileOperation Lib "Shell32" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As Long) As Long
Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pv As Long)
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
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

Then just hide the window using:
fSetAccessWindow(SW_HIDE)

This will hide the Access window.
I use this code religiously.
Love it.. however, whenever there is a problem, and it says to debug, you get windows opening up to your VB code... they still don't see the Access Window, but just like a form displays itself...? The code will display itself...

Hope that helps...
 
Hi Randomlink,

If this is your code then i must say Bravo and thank you as I have used it quite often in a few other db's I've put together and I must say it is really nice - gives applications that "polished" feel.

However, the one other drawback in addition to the one you pointed out about the inability to debug - is that you cannot provide users with the ability to preview reports outside the access window. In these cases I just export the reports into word and then open them from there but you do lose the formatting from the reports in Access.

However, that is a minor grip about an otherwise nifty solution.

This db that I am working on now the users explicitly asked to be able to preview so that why I was working on hiding the db window...

thanks for posting :D
Kevin
 
NOT MY CODE!

Whoa!

I could only WISH this was MY code...

No, thank you but no...
I actually do not know whose code this is (sadly)...
As for the report thing, I agree... that is a pain...
I tried working on other options to view but gave up...
Never thought to export them to word... how clever...

I got this code and use it always on my db's and love it.
I found another batch of code that they used to put an icon in the system tray for the db if you chode to minimize it, but I could never get it to work... ah well...

Well, glad I could be of assitance...
 

Users who are viewing this thread

Back
Top Bottom