Datasheet autosize through code

  • Thread starter Thread starter Charles D Clayton Jr
  • Start date Start date
C

Charles D Clayton Jr

I have a subform that is in datasheet view that is linked to a
listbox. For each item in the list box, the subform will show its BOM
(Bill of Materials). It would be nice if each column would resize
itself to a bestfit. That way I could make maximum use of my space.
Is there a way to set this up automatically?

Thanks,

Charles D Clayton Jr

Running A2K
 
Sub gsbBS_AutoFit(f As Form)
'2003/03/16 dlg from BK
Dim intField As Integer

For intField = 0 To f.Count - 1
If not (TypeOf f(intField) Is Label) Then
f(intField).ColumnWidth = -2
End If
Next

End Sub

(david)
 
David I appreciate your code but which event do I put it in? Do I put
it in the events for the listbox or for the subform?

Thanks,

Charles D Clayton Jr
 
Back
Top