ACC: How to Position Microsoft Access on the Screen (95/97)

ID: Q148856


The information in this article applies to:
  • Microsoft Access versions 7.0, 97


SUMMARY

Advanced: Requires expert coding, interoperability, and multi-user skills.

To position Microsoft Access on the screen, you need to call the SetWindowPos() Windows API function. This article shows you how to call this function to position Microsoft Access on the screen.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.


MORE INFORMATION

To position Microsoft Access on the screen, use the SetWindowPos() application programming interface (API) function included in the User32.dll dynamic link library (DLL) included with Windows. To do so, follow these steps.

NOTE: You may have some Microsoft Windows API functions defined in an existing Microsoft Access library; therefore, your declarations may be duplicates. If you receive a duplicate procedure name error message, remove or comment out the declarations statement in your code.

  1. Open or create a new module in Microsoft Access.


  2. Within the Declarations section, add the following declares, constants, and comments:
    
          '====================================
          ' Global Declarations
          '====================================
    
          Option Compare Database
          Option Explicit
    
          'NOTE: The following declare statement is case sensitive.
    
          Declare Sub SetWindowPos Lib "User32" (ByVal hWnd&, _
                                     ByVal hWndInsertAfter&, _
                                     ByVal X&, ByVal Y&, ByVal cx&, _
                                     ByVal cy&, ByVal wFlags&)
    
          Global Const HWND_TOP = 0            'Moves MS Access window to top
                                               'of Z-order.
    
          'Values for wFlags.
    
          Global Const SWP_NOZORDER = &H4      'Ignores the hWndInsertAfter. 


  3. Type the following function:
    
          Function SizeAccess ()
             Dim cX As Long, cY As Long, cHeight As Long
             Dim cWidth As Long, h As Long
             'Get handle to Microsoft Access.
             h = Application.hWndAccessApp
    
             cX = 0
             cY = 0
             cWidth = 640
             cHeight = 480
    
             'Position Microsoft Access.
             SetWindowPos h, HWND_TOP, cX, cY, cWidth, cHeight, SWP_NOZORDER
    
         End Function 



REFERENCES

For an example of how to position Microsoft Access on the screen in Microsoft Access version 2.0, please see the following article in the Microsoft Knowledge Base:

Q95934 ACC: How to Position Microsoft Access on the Screen

Additional query words: api resize size

Keywords : kbprg
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: October 12, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.