How to Save and Restore Microsoft Access Form Positions Dynamically
Question details
The user wants to dynamically save and restore the position of pop-up forms in Microsoft Access without coordinate mismatches.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Using VBA (like DoCmd.MoveSize) to position forms, but encountering discrepancies between the input coordinates and the actual WindowTop/WindowLeft values.
- Observed behavior
- The saved WindowTop and WindowLeft values differ from the coordinates supplied to DoCmd.MoveSize because Access reports form positions relative to the application window, not the entire screen.
Ensure you have Design View access to your Microsoft Access database and are comfortable writing basic VBA code or creating AutoKeys macros.
Use VBA Form Properties and AutoKeys to Capture Coordinates
Capture the form's coordinates using VBA properties in a fast-ticking timer or macro, store them in a table, and reapply them using DoCmd.MoveSize.
Microsoft Access form positions are calculated relative to the Access application window itself, rather than absolute screen coordinates. Therefore, raw positioning inputs can result in unexpected offsets.
By dynamically capturing the form's actual running properties (WindowTop, WindowLeft, WindowWidth, and WindowHeight) and saving them to your database, you ensure the form restores precisely where you left it.
Add a VBA script to your form's event or a dedicated function. Use the properties `Me.WindowTop`, `Me.WindowLeft`, `Me.WindowWidth`, and `Me.WindowHeight` to read the exact, relative position of the active form.
You can capture these properties silently using the `Form_Timer` event with a fast-ticking timer, or create an `AutoKeys` macro. For example, assign `^1` (Ctrl+1) in AutoKeys to run a code block that saves these values to a dedicated settings table.
On the form's `OnLoad` or `OnOpen` event, retrieve the saved values from your settings table. Pass these values into the `DoCmd.MoveSize` command to automatically position and size the form according to the previously saved state.

Need a Reliable Office Suite? Try WPS Office
While Microsoft Access manages specialized database workflows, WPS Office is an excellent free alternative for handling your everyday documents, spreadsheets, and presentations with a familiar interface and zero learning curve.
- 1. Download WPS Office: Visit the official WPS Office website and download the free installation package for your operating system.
- 2. Install the Suite: Run the installer. The lightweight design ensures the process takes only a few minutes to complete.
- 3. Open Your Microsoft Files: Launch WPS Office and directly open your existing Word, Excel, or PowerPoint files with perfect formatting preservation.

Frequently Asked Questions
Why do the coordinates for DoCmd.MoveSize behave differently than the absolute screen position?
Microsoft Access calculates form positions relative to the main application window's top-left corner. If you are expecting absolute screen coordinates, the form will appear offset by the position of the main Access window itself.
What units of measurement does DoCmd.MoveSize use in Access?
DoCmd.MoveSize and standard Access position properties use 'twips'. There are 1,440 twips in one logical inch. If you want a form to be 2 inches wide, you would pass 2880 for the width parameter.
How do I create an AutoKeys macro in Microsoft Access?
Go to the Create tab, click Macro, and save it exactly with the name 'AutoKeys'. In the macro design grid, use the Macro Name column to define shortcuts (e.g., ^1 for Ctrl+1) and assign an Action, like RunCode, to trigger your VBA function.




