Anton
Anton

Reputation: 79

Minimize MS Access Window Leaving POPUP Form

I have the below code to minimize MS access but the pop up forms disappear with the background...

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

does anyone have any idea how i can leave the popup form and just minimize access background?

Upvotes: 1

Views: 4289

Answers (2)

Brilstern
Brilstern

Reputation: 1

The trick is to use the Form.SetFocus cmd afterwards. As the main screen minimizes the SetFocus cmd after will keep the form up:

Private Sub cmdMinimize_Click()
        Call fSetAccessWindow(SW_SHOWMINIMIZED)
        Form.SetFocus
End Sub

Upvotes: 0

Freeman Helmuth
Freeman Helmuth

Reputation: 190

The only way I know of to do this is to put the call fSetAccessWindow(SW_SHOWMINIMIZED) in the form_load event. This works reliably for me

Upvotes: 1

Related Questions