Does anyone have a code resource for determining the actual used width
of a form?
I would like to know the minimum width that a form can have without
hiding any of it's controls/subforms.
Damon Heron - 08 Mar 2007 19:42 GMT
You could loop thru all the controls on the form and add the control's left
and width properties, which will give you the right most number of the
control (in twips). You could store results in an array and find the
largest number, which would be the fartherest right point of a control. I
am winging it here, don't have any code other than a
Debug.Print Me![somecontrol].Left + Me![somecontrol].Width
HTH get you started
Damon
> Does anyone have a code resource for determining the actual used width
> of a form?
> I would like to know the minimum width that a form can have without
> hiding any of it's controls/subforms.
Douglas J. Steele - 08 Mar 2007 19:58 GMT
Loop through the Controls collection, and find the largest values of Left +
Width for the form:
Dim ctlCurr As Control
Dim lngMaxSize As Long
For Each ctlCurr In Me.Controls
With ctlCurr
If .Left + .Width > lngMaxSize Then
lngMaxSize = .Left + .Width
End If
End With
Next ctlCurr
MsgBox "The form needs to be at least " & _
lngMaxSize & " twips."

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Does anyone have a code resource for determining the actual used width
> of a form?
> I would like to know the minimum width that a form can have without
> hiding any of it's controls/subforms.