By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,039 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,039 IT Pros & Developers. It's quick & easy.

Miinimize the Access Application window

P: 6
I want to minimize the Access Application by a button click. However, docmd.runcommand accmdappminimize is not working and DoCmd.minimize is work just to minimize the forms.
Jun 7 '18 #1

✓ answered by twinnyfo

681212,

Welcome to Bytes!

The easiest way I can assist is to simply provide a Function that I use all the time. You can put this in a new module:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. '==============================
  5. '  CONSTANTS FOR DBASE WINDOW
  6. '==============================
  7.  
  8. Private Const DB_Hide = 0
  9. Private Const DB_Normal = 1
  10. Private Const DB_Minimized = 2
  11. Private Const DB_Maximized = 3
  12.  
  13.  
  14. '==========================
  15. '  DBASE WINDOW FUNCTIONS
  16. '==========================
  17.  
  18. Public Declare Function IsWindowVisible Lib "user32" _
  19.     (ByVal hwnd As Long) _
  20.     As Long
  21.  
  22. Public Declare Function ShowWindow Lib "user32" _
  23.     (ByVal hwnd As Long, _
  24.     ByVal nCmdShow As Long) _
  25.     As Long
  26.  
  27. '============================
  28. ' FORM MANAGEMENT FUNCTIONS
  29. '============================
  30.  
  31. Public Function fAccessWindow( _
  32.     Optional Procedure As String, _
  33.     Optional SwitchStatus As Boolean, _
  34.     Optional StatusCheck As Boolean) As Boolean
  35. '***********************************************************************************
  36. '* Purpose:  Controls the behavior and appearance of the Database Window            *
  37. '* Accepts:  Procedure    - (Optional) Describes the behavior requested            *
  38. '*           SwitchStatus - (Optional) Instructs the procedure to switch the       *
  39. '*                          current status of the DB Window                        *
  40. '*           StatusCheck -  (Optional) Allows the procedure to check the current   *
  41. '*                          status of the DB window to determine whether or not to *
  42. '*                          initiate a change                                      *
  43. '***********************************************************************************
  44. On Error GoTo EH
  45.     Dim dwReturn As Long
  46.  
  47.     Select Case Procedure
  48.         Case "Hide"
  49.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Hide)
  50.         Case "Minimize"
  51.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Minimized)
  52.         Case "Normal"
  53.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Normal)
  54.         Case "Show"
  55.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Maximized)
  56.     End Select
  57.  
  58.     If SwitchStatus = True Then
  59.         If IsWindowVisible(hWndAccessApp) = 1 Then
  60.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Hide)
  61.         Else
  62.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Maximized)
  63.         End If
  64.     End If
  65.  
  66.     If StatusCheck = True Then
  67.         If IsWindowVisible(hWndAccessApp) = 0 Then
  68.             fAccessWindow = False
  69.         End If
  70.  
  71.         If IsWindowVisible(hWndAccessApp) = 1 Then
  72.             fAccessWindow = True
  73.         End If
  74.     End If
  75.  
  76.     Exit Function
  77. EH:
  78.     MsgBox "There was an error resetting the Database Window!  " & _
  79.         "Please contact your Database Administrator.", vbCritical, "WARNING!"
  80.     Exit Function
  81. End Function
To call this Function, just use this statement in your VBA:

Expand|Select|Wrap|Line Numbers
  1. fAccessWindow "Minimize"
Hope this hepps!

Share this Question
Share on Google+
2 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,284
681212,

Welcome to Bytes!

The easiest way I can assist is to simply provide a Function that I use all the time. You can put this in a new module:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. '==============================
  5. '  CONSTANTS FOR DBASE WINDOW
  6. '==============================
  7.  
  8. Private Const DB_Hide = 0
  9. Private Const DB_Normal = 1
  10. Private Const DB_Minimized = 2
  11. Private Const DB_Maximized = 3
  12.  
  13.  
  14. '==========================
  15. '  DBASE WINDOW FUNCTIONS
  16. '==========================
  17.  
  18. Public Declare Function IsWindowVisible Lib "user32" _
  19.     (ByVal hwnd As Long) _
  20.     As Long
  21.  
  22. Public Declare Function ShowWindow Lib "user32" _
  23.     (ByVal hwnd As Long, _
  24.     ByVal nCmdShow As Long) _
  25.     As Long
  26.  
  27. '============================
  28. ' FORM MANAGEMENT FUNCTIONS
  29. '============================
  30.  
  31. Public Function fAccessWindow( _
  32.     Optional Procedure As String, _
  33.     Optional SwitchStatus As Boolean, _
  34.     Optional StatusCheck As Boolean) As Boolean
  35. '***********************************************************************************
  36. '* Purpose:  Controls the behavior and appearance of the Database Window            *
  37. '* Accepts:  Procedure    - (Optional) Describes the behavior requested            *
  38. '*           SwitchStatus - (Optional) Instructs the procedure to switch the       *
  39. '*                          current status of the DB Window                        *
  40. '*           StatusCheck -  (Optional) Allows the procedure to check the current   *
  41. '*                          status of the DB window to determine whether or not to *
  42. '*                          initiate a change                                      *
  43. '***********************************************************************************
  44. On Error GoTo EH
  45.     Dim dwReturn As Long
  46.  
  47.     Select Case Procedure
  48.         Case "Hide"
  49.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Hide)
  50.         Case "Minimize"
  51.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Minimized)
  52.         Case "Normal"
  53.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Normal)
  54.         Case "Show"
  55.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Maximized)
  56.     End Select
  57.  
  58.     If SwitchStatus = True Then
  59.         If IsWindowVisible(hWndAccessApp) = 1 Then
  60.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Hide)
  61.         Else
  62.             dwReturn = ShowWindow(Application.hWndAccessApp, DB_Maximized)
  63.         End If
  64.     End If
  65.  
  66.     If StatusCheck = True Then
  67.         If IsWindowVisible(hWndAccessApp) = 0 Then
  68.             fAccessWindow = False
  69.         End If
  70.  
  71.         If IsWindowVisible(hWndAccessApp) = 1 Then
  72.             fAccessWindow = True
  73.         End If
  74.     End If
  75.  
  76.     Exit Function
  77. EH:
  78.     MsgBox "There was an error resetting the Database Window!  " & _
  79.         "Please contact your Database Administrator.", vbCritical, "WARNING!"
  80.     Exit Function
  81. End Function
To call this Function, just use this statement in your VBA:

Expand|Select|Wrap|Line Numbers
  1. fAccessWindow "Minimize"
Hope this hepps!
Jun 7 '18 #2

P: 6
Wonderful.. Thanks Twinnyfo
Jun 7 '18 #3

Post your reply

Sign in to post your reply or Sign up for a free account.