Hiding the main MS Access program window (1 Viewer)

RevJeff

Registered User.
Local time
Yesterday, 23:56
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
 

John.Woody

Registered User.
Local time
Today, 04:56
Joined
Sep 10, 2001
Messages
354
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
 

RevJeff

Registered User.
Local time
Yesterday, 23:56
Joined
Sep 18, 2002
Messages
125
That worked great!!!

Thanks!
 

Scott767

New member
Local time
Yesterday, 23:56
Joined
Nov 27, 2011
Messages
2
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:

speakers_86

Registered User.
Local time
Yesterday, 23:56
Joined
May 17, 2007
Messages
1,919
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.
 

Scott767

New member
Local time
Yesterday, 23:56
Joined
Nov 27, 2011
Messages
2
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
 

drb555

Registered User.
Local time
Today, 06:56
Joined
Jul 10, 2013
Messages
19
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
 

DavidPhillips

New member
Local time
Yesterday, 22:56
Joined
Nov 30, 2013
Messages
4
Try adding a form restore before the command to hide the access window.

Application.DoCmd.Restore
 

drb555

Registered User.
Local time
Today, 06:56
Joined
Jul 10, 2013
Messages
19
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
 

optimuz

New member
Local time
Yesterday, 20:56
Joined
Jun 25, 2016
Messages
3
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
 

symocarl

New member
Local time
Yesterday, 20:56
Joined
Nov 28, 2017
Messages
1
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

Top Bottom