ACC2: How to Dynamically Size Forms to Fit Screen Resolution

This article was previously published under Q138901
This article has been archived. It is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.
Microsoft Access provides no built in support to scale a form's size tomatch the current screen resolution. A form that you design on a computerwith a video driver resolution of 1024x768 (Super VGA) may appear too largeon computers running at 640x480 (VGA) resolution. A form that you designusing 640x480 resolution may appear too small on computers running at1024x768 resolution.

The following information describes where you can obtain two Access Basicfunctions, glrScaleForm() and glrResizeForm(), that you can use todynamically scale and size a form. The glrScaleForm() function can becalled from the Open event of your form to scale the size of a form to thecurrent screen resolution when the form loads. The glrResizeForm() can becalled from the Resize event of the form to automatically move and size thecontents of a form proportionally to fit the new dimensions of the formwindow.


The glrScaleForm() function can be called from the Open event of your formto automatically scale the form to the current screen resolution.
   Syntax:      Function glrScaleForm (frm As Form, intX As Integer, intY As Integer)      frm:  form to be scaled      intX: horizontal resolution at which the form was designed      intY: vertical resolution at which the form was designed   Example:      Sub Form_Open (Cancel As Integer)         Dim RetVal         RetVal = glrScaleForm(Me, 1024, 768)      End Sub				


The glrResizeForm() function can be called from the Resize event of yourform to automatically move and resize the contents proportionally to fitwithin the new form window size.
   Syntax:      Function glrResizeForm (frm As Form, fDoResize As Variant)      frm:       form to resized      fDoResize: boolean value indicating if the form should be resized or                 the information tracked   Example:      Sub Form_Resize ()         Dim RetVal         RetVal = glrResizeForm(Me, True)      End Sub				

How To Obtain The glrScaleForm And glrResizeForm Functions

The glrScaleForm() and glrResizeForm() functions, written by Ken Getz, arepublished in the following book:
   Microsoft Access 2 Developer's Handbook. Ken Getz, Paul Litwin,   Greg Reddick. Sybex: 1994 ISBN: 0-7821-1327-3				

Discussion of these function begins on page 506, chapter 8, "ScreenResolution and Distributing Forms." The functions are included in the file_Glrfile.exe on the accompanying companion disk. This self-extracting,compressed file contains the file _Chapter.exe, another self-extracting,compressed file, which contains the database CH8.mdb. The formfrmTest1280x1024 in CH8.mdb demonstrates the use of these functions. Checkthe "Enable Automatic Resizing?" check box in the upper-left corner ofthe form frmTest1280x1024, and then resize the form window to see theglrResizeForm() function work.

These functions were originally published with a column in Smart Accessmagazine.
   "Create Resolution-Independent Forms in Access 2.0" by Ken Getz   Smart Access, June 1994				

Smart Access, published monthly, is a newsletter aimed at MicrosoftAccess developers. It is published by Pinnacle Publishing.
   Pinnacle Publishing, Inc.   18000 72nd Ave South, Suite 217   Kent, WA 98032   800-788-1900				

The products discussed here are manufactured by vendors independent ofMicrosoft; we make no warranty, implied or otherwise, regarding theseproducts' performance or reliability.

Article ID: 138901 - Last Review: 12/04/2015 12:16:00 - Revision: 1.0

Microsoft Access 2.0 Standard Edition

  • kbnosurvey kbarchive kb3rdparty kbhowto KB138901