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

Last reviewed: August 28, 1997
Article 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 gives a brief demonstration of how 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, to 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:

   ARTICLE-ID: Q95934
   TITLE:      ACC2: How to Position Microsoft Access on the Screen


Additional query words: api resize size
Keywords : kbprg PgmApi
Version : 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.