Width property of form

V

Victoria

I have a form that shows what is normally needed by the user. I want to be
able to click a button labelled 'Extend' to widen the form to the right,
revealing details not normally needed. Why doesn't this code fragment work
in the button's On Click event?

Forms!frmOrders.Width = 10080
 
R

Rob Parker

Try resizing the window to fit the new form's width. The form size and the
window size are not the same thing.

Forms!frmOrders.Width = 10080
DoCmd.RunCommand acCmdSizeToFitForm

HTH,

Rob
 
V

Victoria

Rob - that's perfect
thanks!

Rob Parker said:
Try resizing the window to fit the new form's width. The form size and the
window size are not the same thing.

Forms!frmOrders.Width = 10080
DoCmd.RunCommand acCmdSizeToFitForm

HTH,

Rob
 
V

Victoria

hello Rob - I spoke too soon. The 'more details' button works exactly as you
said it would, expanding the window to reveal 'more details' on the form's
right side. But the 'less details' button (both buttons are superimposed with
only one visible at a time) doesn't work. When I set the form width to, say
6000 then use DoCmd.RunCommand acCmdSizeToFitForm, the Window will not shrink
enough to hide any controls. It only will shrink to the right edge of the
furthest right textbox. I need to be able to cover these areas of the form.
Any more clues?

Thank you
 
S

Sophie

I think you are looking for something like this.

DoCmd.MoveSize 5440, 3400, 12000, 8150

Hope this helps
 
R

Rob Parker

Hi Victoria,

You can't set the form width to less than the position of the right-hand
edge of the right-most control(s); although you may be attempting to do so
in code, the command will simply set the width to the minimum possible
width, rather than the actual value you specify (and no error is generated).
The SizeToFitForm command will always show these controls, and it will only
resize the form to the edge of these controls (even if they are hidden).

Rather than resizing your form, you should use the MoveSize command to
resize the window. This command takes up to four parameters - right, down,
width, height; any parameters omitted are not changed. For example:
DoCmd.MoveSize , , 2000
will resize the window to 2000 twips wide, without changing its position or
height.

If your form has scrollbars enabled, the resize (to a narrower width) will
probably cause a horizontal scrollbar to appear. You can prevent this by
setting the form's scrollbar property to either Vertical or None.

HTH,

Rob
 
Top