ID: Q148856
The information in this article applies to:
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.
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
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 : ACC: How to Position Microsoft Access on the Screen
Additional query words: api resize size
Keywords : kbprg
Version : 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto
Last Reviewed: November 20, 1998