ACC2000: How to Use Visual Basic for Applications to Minimize, Maximize, and Restore Access (210090)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q210090
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SUMMARY

This article shows you how to use Visual Basic for Applications code to maximize, minimize, and restore Access.

You can use the RunCommand action to maximize, minimize, and restore Access. For example, you can use the following:
  DoCmd.RunCommand acCmdAppMaximize
  DoCmd.RunCommand acCmdAppMinimize
  DoCmd.RunCommand acCmdAppRestore
				
If you are using Automation, you can use the following:
  application.DoCmd.RunCommand acCmdAppMaximize
  application.DoCmd.RunCommand acCmdAppMinimize
  application.DoCmd.RunCommand acCmdAppRestore
				

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. You can also write Visual Basic for Applications functions that use Windows API calls to maximize, minimize, and restore the current Application window. To see an example of this, follow these steps:
  1. In a new Access database, click Modules, and then click New. The Visual Basic Editor appears.
  2. Type or paste the following code:
    Option Explicit
    
       Global Const SW_SHOWNORMAL = 1
       Global Const SW_SHOWMINIMIZED = 2
       Global Const SW_SHOWMAXIMIZED = 3
    
       Declare Function ShowWindow Lib "User32" (ByVal Hwnd As Long, _
           ByVal nCmdShow As Long) As Long
    
    Function MaximizeApp()
       Dim Maxit%
       Maxit% = ShowWindow(hWndAccessApp, SW_SHOWMAXIMIZED)
    End Function
    
    Function MinimizeApp()
       Dim Minit%
       Minit% = ShowWindow(hWndAccessApp, SW_SHOWMINIMIZED)
    End Function
    
    Function RestoreApp()
       Dim Restoreit%
       Restoreit% = ShowWindow(hWndAccessApp, SW_SHOWNORMAL)
    End Function
    					
  3. Save the module, and then close the Visual Basic Editor.
  4. Create a new form called MyForm, and then create the following command button:
       Command button
       ------------------------
       Name: MinAcc
       Caption: Minimize Access
       OnClick: =MinimizeApp()
    					
  5. Save the form, and then open the form in Form view.
  6. Click the Minimize Access button to see Access minimized.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbhowto kbinfo kbProgramming KB210090