Page 1 Page 2

First Published 26 July 2026 Difficulty level :   Moderate




The first article in this series showed how forms could be docked to any specified position on the Access window using a selection in a combo box or option group.

The code worked correctly for a wide variety of situations using both standard and popup forms:
•   Access window maximised or only occupying part of the screen
•   Ribbon maximised/minimised/hidden
•   Navigation Pane maximised/minimised/hidden
•   Full-screen Mode
•   different values for the application default zoom level

However, an important issue is that the original code didn't take into account any changes to zooming after the form has opened.
This is because the Access interface and form window dimensions were not re-calculated after the form has loaded.

This article provides modified code that overcomes this issue. The module code remains unchanged.
However, the form code has been updated to re-calculate the dimensions whenever the zoom level (or the Access window size) is changed. For example:

Standard Form - Docked with Zoom = 140%

Standard Form Docked - Zoom = 140%
Popup Form - Docked with Zoom = 120%

Popup Form Docked - Zoom = 120%


Video

Coming soon



Changes to Form Code

The updated code now includes several form level variables:

Option Compare Database
Option Explicit

Dim sngZoom As Single, sngOldZoom As Single
Dim lngWidth As Long, lngHeight As Long
Dim blnDrag As Boolean


The Form_Load event now has two additional code lines to get the original width and height of the form and save it as variables lngWidth and lngHeight.

Private Sub Form_Load()

Dim fw As New clFormWindow

fw.hWnd = Me.hWnd

With fw
'Get original size (v2.2)
lngWidth = .Width
lngHeight = .Height

'move to center
.Top = (.Parent.Height - .Height) / 2
.Left = (.Parent.Width - .Width) / 2
End With

Set fw = Nothing

'get captions for labels in form footer
GetFormFooterCaptions Me

Me.txtZoom = Me.Properties("Zoom")

End Sub


The code used to drag the form has two extra lines. These clear the option group (or combo box) position value and set the blnDrag variable to True:

Private Sub cmdDragForm_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'drag form to new position
X = ReleaseCapture()
X = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HT_CAPTION, 0)

'clear the option group setting & set boolean variable true
Me.fraPosition = 0 'v2.2
blnDrag = True 'v2.2
End Sub


The option group (or combo box) AfterUpdate event resets blnDrag to False, indicating that the position has been reset:

Private Sub fraPosition_AfterUpdate()

Dim fw As New clFormWindow

blnDrag = False 'v2.2

fw.hWnd = Me.hWnd

With fw

Select Case Me.fraPosition

Case 1 'Top Left
.Top = 0
.Left = 0

Case 2 'Centre Left
' Access window - form - Access window scrollbar
.Top = (.Parent.Height - .Height) / 2
.Left = 0

Case 3 'Bottom Left
' Access window - form - Access window scrollbar
.Top = .Parent.Height - .Height - 1440 / 255
.Left = 0

Case 4 'Top Centre
' Access window - form - Access window scrollbar
.Top = 0
.Left = (.Parent.Width - .Width) / 2

Case 5 'Centred
.Top = (.Parent.Height - .Height) / 2
.Left = (.Parent.Width - .Width) / 2

Case 6 'Bottom Centre
' Access window - form - Access window scrollbar
.Top = .Parent.Height - .Height - 1440 / 255
.Left = (.Parent.Width - .Width) / 2

Case 7 'Top Right
' Access window - form - Access window scrollbar
.Top = 0
.Left = .Parent.Width - .Width - 1440 / 255

Case 8 'Centre right
' Access window - form - Access window scrollbar
.Top = (.Parent.Height - .Height) / 2
.Left = .Parent.Width - .Width - 1440 / 255

Case 9 'Bottom right
' Access window - form - Access window scrollbar
.Top = .Parent.Height - .Height - 1440 / 255
.Left = .Parent.Width - .Width - 1440 / 255

End Select

End With
Set fw = Nothing

End Sub


A Form_Timer event runs each second (TimerInterval = 1000) and is used to check the current zoom level. When the zoom level changes, the form is resized in proportion to the new zoom value.

In addition, unless the form has been dragged to a new position, the AfterUpdate event runs again and the form is then repositioned correctly.

Private Sub Form_Timer()

'NEW v2.2

Dim fw As New clFormWindow

'check zoom
sngZoom = Me.Properties("Zoom") / 100

Me.txtZoom = Me.Properties("Zoom")

fw.hWnd = Me.hWnd

If sngZoom <> sngOldZoom Then
'adjust form size if zoom has changed
With fw
.Width = sngZoom * lngWidth
.Height = sngZoom * lngHeight
End With
End If

'update old zoom value
sngOldZoom = sngZoom

'recheck position
If Not blnDrag Then fraPosition_AfterUpdate

End Sub


NOTE:
1.   If the form has been manually dragged to a new position (blnDrag = True), the form is resized on zoom change but its relative position is left unaltered.
2.   The supplied code will always open popup forms on the primary monitor even if the Access window is on another screen.
3.   The code used to reposition forms after zoom changes will only work correctly for one form opened at any time.



Download

Click to download:
     DockForms_v2.2      ACCDB file - approx 0.8 MB (zipped) - designed for Access 365 version 2607 or later

NOTE: Zooming of standard forms is only supported in Access 365 from version 2605. For popup forms, version 2607 or later is required

As is the case for all files downloaded from the internet, first unblock the downloaded file, unzip it, then save to a trusted location.
For more details, see my article: Unblock downloaded files by removing the Mark of the Web



Feedback

Please use the Email button in the contact form below to let me know whether you found this article useful or if you have any questions.

Please also consider making a donation towards the costs of maintaining this website. Thank you


Colin Riddington Mendip Data Systems Last Updated 26 July 2026




Return to Access Articles Page Page 2 of 2 1 2 Return To Top