Hiding the main MS Access program window

RevJeff

Registered User.
Local time
Today, 07:08
Joined
Sep 18, 2002
Messages
125
Hi,

I have a Access 2010 database that loads a form when it opens with both "Pop up" and "Modal" set to yes.

My question is: Is there a way of minimizing or hiding the main MS Access program window when it loads the form so you don't see it in the background behind the form.

Thanks,

Jeff
 
Try saving this to a module
Code:
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

Then in your form's ON Load
Code:
Call fSetAccessWindow(0)

Change the value to suite as above.

It works for access 2002/03, but havn't tried it with 2010.

HTH
 
That worked great!!!

Thanks!
 
Hi All,

I am need of some assistance, in the attached code. How do you handle a 'datasheet?' I understand the form piece, but I am having issues allowing a datasheet to pop up too. Any assistance would be greatly appreciated. I am utilizing MS Access 2010.

Thank you in advance.

Scott
 
Last edited:
What issues are you having? Datasheets can be pop up too. An alternative would be to use a blank form and shove your datasheet there as a subform. I usually think that looks better anyway, and reduces the issue of datasheets changing their form size every time you go to design view.
 
I currently have a datasheet form created, but with how the code is written, it doesn't allow it to show. Only modification I made to the original code for Forms is as follows: loX = apiShowWindow(hWndAccessApp, SW_HIDE). I am pretty sure it has something to do with the view: datasheet (in the form properties), not form. I have created a second module to accept the form and modifed: screen.activedatasheet. The issue is now, that the Access Database Window is minimized in the taskbar, which I do not want it to show. How do I remove MS Access Icon from the taskbar? Here is the code from the new module for datasheets:

Function fSetAccessWindow(nCmdShow As Long)
Dim loX As Long
Dim loDatasheet As Form
On Error Resume Next
Set loDatasheet = Screen.ActiveDatasheet
If err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
err.Clear
End If
If nCmdShow = SW_HIDE And loDatasheet.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loDatasheet.Caption + " ") _
& "datasheet on screen"
ElseIf nCmdShow = SW_HIDE And loDatasheet.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loDatasheet.Caption + " ") _
& "datasheet on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
fSetAccessWindow = (loX <> 0)
End Function

Thank you,
Scott
 
when hiding the access window is there a way to put an icon on the taskbar as at the moment no access database shows on the task bar and I have to alt tab through open apps to find the open form
 
Try adding a form restore before the command to hide the access window.

Application.DoCmd.Restore
 
Try adding a form restore before the command to hide the access window.

Application.DoCmd.Restore
I tried that but still no icon on the task bar.
I am using access 2000 if that makes a difference
 
hi im from Sri Lanka... just got this sorted out on my own...

annnnndddd it works clean...

heres how..

1. Create a macro just go to Create--> macro
2. in the action field type or find using the drop down list "Run Command"
3. in the action arguments form below ( not right after the action field, just look below) in the "Command" field select "appMinimize"
4.then in the action field find a second value "openForm"
5. in the arguments field you can give your desired form to pop up, it's state, any filters,windows state and all.
6. save all & rename the Macro as AutoExec
7. happily close your database and open... BOOM... you got the miracle in simple steps..
8. if anyone ran to a situation where nothing could editable again... please open your database while pressing the SHIFT KEY as a life saver.
9. and i recomend you to first create a good set of navigation amoung your forms so that it will be another application like database.
10. YOU KNOW WHAT... I am a NewBee .... hope you like this

Thanks
 
Try saving this to a module
Code:
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

Then in your form's ON Load
Code:
Call fSetAccessWindow(0)

Change the value to suite as above.

It works for access 2002/03, but havn't tried it with 2010.

HTH

Hello John,

This is great. I used this and it did exactly the right thing. The only problem is..... I now can't get to the access window at all... Is there anything I can do to fix this? I hadn't saved another copy before trying it - which was a stupid more, I know!

Any help you can offer would be greatly appreciated!

Thanks,

Carl
 

Users who are viewing this thread

Back
Top Bottom