Actual 'used' width of a form

R

robert.waters

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.
 
D

Damon Heron

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
 
D

Douglas J. Steele

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."
 
Top