troubleshooting Question

Can't minimize my access application

Avatar of sonmic
sonmic asked on
Microsoft Access
11 Comments1 Solution1098 ViewsLast Modified:

I want to minimize my access application when not needed. I have the code downloaded from the internet (see appendix). The SW_HIDE works fine but i cannot minimize. I get always an error because the active form is open.
How can i solve this.

Option Compare Database
Option Explicit

Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1

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 = Forms("frm_hoofdscherm").Form
    If Err <> 0 Then 'no Activeform
      If nCmdShow = SW_HIDE Then
        MsgBox "Cannot hide Access unless " _
                    & "a form is on screen"
        loX = apiShowWindow(hWndAccessApp, nCmdShow)
      End If
        If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
            MsgBox "Kan access niet minimaliseren met " _
                    & (loForm.Caption + " ") _
                    & "form op het scherm."
        ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
            MsgBox "Cannot hide Access with " _
                    & (loForm.Caption + " ") _
                    & "form on screen"
            loX = apiShowWindow(hWndAccessApp, nCmdShow)
        End If
    End If
    fSetAccessWindow = (loX <> 0)
End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros