Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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
				

↑ Back to the top


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.

↑ Back to the top


Keywords: KB210090, kbprogramming, kbinfo, kbhowto

↑ Back to the top

Article Info
Article ID : 210090
Revision : 5
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 538