Resizing a form programmatically

  • Thread starter Thread starter John S. Ford, MD
  • Start date Start date
J

John S. Ford, MD

I'm using Access 97. I've written some code designed to resize control's
Width and Height properties and to readjust their positions on a form (Top,
Left properties). Unfortunately, although it works, none of the changes are
reflected in the controls DEFAULT properties. Therefore, the form opens the
same way each time (using the default properties. Is there a way of
programmatically altering the form controls default properties?

John
 
To alter the "default" properties (I assume you mean the values in the
Properties sheet), you need to open the form in design mode, make the
changes, save the changes, and close the form. This can be done in code if
you wish.

To change the "default" properties for a type of control, such as a textbox,
as you add a new one to the form you can create a template form to use. I'm
not sure, though which version of Access was the first to implement this.
 
Lynn,

I try putting it in the OnOpen event and although the form opens with the
controls moved and sized correctly, the changes don't persist when the form
is closed.

John
 
No. I won't persist.

If you need the Properties of the Controls to be saved with the *design* of
the Form, you need to open (by code from now on if you wish) the Form in
DesignView, set the Properties of the Controls and finally save the design
of the Form.

OTOH, using Open (or Load) Event, the Controls will appear correctly when
you open the Form, anyway.
 
Thanks Wayne,

Opening the form in design view and moving and resizing the controls
programmatically worked perfectly.

Thanks,
John
 
Back
Top