How to minimize main Access window with opened MODAL form, using code in this form?

J

John Smith

I try to do it with following code (without checking is modal form open)
using SW_SHOWMINIMIZED or SW_MINIMIZE constants:

'ShowWindow constants
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Const SW_SHOWDEFAULT = 10

Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Function fSetAccessWindow(nCmdShow As Long)
'Code Courtesy of
'Dev Ashish & Terry Kreft
'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

It works good: I see minimized Access window on task bar. But then, when I
try click it on task bar, it can't be restore back to normal size. I have to
open task manager and end Access task manually :(.

Could somebody explane how I can solve this problem?
 
A

Alexander Nikiforov

Sorry, but it does not work: when I push bottom in form with this code, main
Access window does't minimize to task bar :(.
 
V

Van T. Dinh

acCmdAppMinimize worked fine when I tested it in A2K with Modal Form but NOT
Popup (and repeated just now).

If you have the Form popped up, it won't work as this Popup Form is more or
less "separated" from Access.

A97 and A2K behave differently because of the "Windows in Taskbar" feature.
If you use A97, you need to check different combination.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Minimize access windows 0
Menu bar not showing after API Call 7
Hiding Access Window 1
Hiding Access 3
Code to restore MS-Access window 1
Restoring MS-Access Window 3
Reports not showing 0
Hide Access Window 5

Top