Skip to content

Size to Fit Form

Using the Size to Fit Form.

Q:  Peter Farren writes “I would be grateful if you could clarify for me usage of the acCmdSizeToFitForm constant.  For example, the Load Event of frmInvoices in Archon Column 114 consists of:

      DoCmd.RunCommand acCmdSizeToFitForm

 

I assume that the RunCommand method is applied to the Subform fsubCompanyInfo.  Once the Size to Fit command has been run in Design View is it necessary to repeat the command each time the form is loaded?”

A:  RunCommand belongs to the Access Application object, not to a form or any other specific object.  The DoCmd object has been held over from earlier versions of Access for backwards compatibility; you can also use the syntax

      Application.RunCommand acCmdSizeToFitForm

 

When you use the acCmdSizeToFitForm constant, it sizes the main form.  It has no effect on any subforms on that form.  The reason I put the command in the Form_Load event is to resize the form in case it has been manually resized, which happens occasionally.

About this author