Hopefully this isn't too confusing, but I need a way to run VBA code when Access is no longer minimized.
Background:
I have a database where I've been using the Popup feature on my forms but I hide access window using the following code: (found it online, but it does exactly what I needed)
Code:
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
So when us Call Hide_App_Window.fSetAccessWindow(#), where the # is a number 0-3, I get these results.
0 = Hide (can't see access window, or the access icon on the task bar)
1 = Normal View
2 = Minimized
3 = Maximized
The problem I'm having is when I use 0 the user can't minimize it. So I created a button that does that (Call Hide_App_Window.fSetAccessWindow(2)) but now when the user clicks on it in the taskbar to make it visible (technically normal view) you see the access window when it opens back up.
I need someway of running the Call Hide_App_Window.fSetAccessWindow(0) code anytime access is no longer minimized.
Any ideas would be more than welcome. Also, put some jpgs of what I want to happen and not happen below
Thank you very much!