Freelance Project Requests Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net


Datei 1: Autoscale.accdb



the following vba code example shows how to automatically customize Microsoft Access Database forms to the maximum width of the current monitor

All controls such as text box or label elements are moved to the corresponding positions at run time and adjusted in width and height.


This is especially useful for notebook versions under FullHD and parallel desktop workstations with maximum resolution.

Microsoft Access, auto scaling to maximum width with vba code


Form Customization, AutoScale, Auto Scale


In the code, the AutoSkale-vba code is executed when you click on the Resize button.

Of course, the vba code can also be pushed in the form for OnLoad and On_Open.


auto-scaling, autoScale

Automatically scaled to the maximum width and height of the monitor in Windows 10


Vba Code

Vba Code for the Microsoft Access Application


Option Compare Database

Option Explicit On


Private Sub BtnResize_Click()

    '------------< Resize >-------------

    '-< Get_Scale >-

    '< X >


    Dim xStart As Long

    xStart = Me.Width

    If xStart < 0 Then

        xStart = (32768 / 2) - xStart

    End If


    Dim xWindow As Long

    xWindow = Me.WindowWidth

    If xWindow < 0 Then

        xWindow = (32768 / 2) - xWindow

    End If

    If xWindow > 31000 Then xWindow = 31000

    'max integer=32767

    'maximale breite=2.048 lt Microsoft




    Dim ScaleX As Double

    ScaleX = xWindow / xStart

    '</ X >


    '< Y >


    Dim yStart As Long

    yStart = Detailbereich.Height 'Section(0).Height



    Dim yHeader As Long

    yHeader = Section(1).Height


    Dim yFooter As Long

    yFooter = Section(2).Height


    'Status=30 Commandbar=30 ApplicationTitle=30 Counter=30

    Dim yOffset As Long

    yOffset = 90


    Dim yWindow As Long

    yWindow = Me.WindowHeight - yHeader - yFooter + yOffset


    Dim ScaleY As Double

    ScaleY = yWindow / yStart

    '</ Y >


    '-</ Get_Scale >-

    Dim ctl As Control

    For Each ctl In Me.Controls

        ctl.Left = ctl.Left * ScaleX

        ctl.Width = ctl.Width * ScaleX


        If ctl.Section = 0 Then

            ctl.Top = ctl.Top * ScaleY



            'On Error Resume Next

            ctl.Height = ctl.Height * ScaleY


        End If


    '------------</ Resize >-------------

End Sub




Automatically adjust Access forms to the maximum monitor size
Access: insert special characters in vba
VBA function: Convert numbering to number
Access vba: Create Numbering as default values
Vba: Option Explicit
VBA: Option Explicit


Contact for Jobs, Project Requests: