Adjusting the size of a subform using code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform that has a "TOTALS" textbox that is a calculated field. The
number of line items in it will change for each customer. I tried adding up
the heights of the form header & footer(0.1667) + Count of line items *
0.1667 so that the TOTALS will be right under the last line item. The CanGrow
and CanShrink on the subform and the subform details section are set to Yes.
I tried running this code and refresh the form and it does not work....

Any ideas?

TIA Craig
 
Hi Craig

You need to change the height of the subform control that contains your
subform.

You are on the right track with adding up the different section heights, but
remember that the unit is TWIPs (TWentIeths of a Point), so there are 1440
TWIPs per inch.

Something like this should get you going:

dim iHeight as integer
With Me.SubformControl.Form
iHeight = .Section(acHeader).height + .Section(acFooter).Height _
+ .Section(acDetail).height * .RecordsetClone.RecordCount
End With
Me.SubformControl.Height = iHeight

You might need to add on a few TWIPs (50 or so) to allow for dividing lines
and borders.
 
Back
Top