Can Grow property on a sub form

  • Thread starter Thread starter frank
  • Start date Start date
F

frank

Hello,

I have a main form that contains a sub form. The sub form
is a continuous form that has the Can Grow propery set to
yes. When the main form is displayed, the sub form is not
growing and showing all records in the sub form at once.
How do i get the sub form to grow for however many records
are in the sub form? Basically, the main form contains
data infront of and after the sub form so I need the sub
form to grow dynamically.

Thanks in advance
 
Not sure if this is any help but...

The CanGrow and CanShrink property only allows controls
(within the detail section) of a form/subform to display
more of the data for a SINGLE record. So if you have
a 'Notes' field for example, you don't have to set the
control to 3 inches deep to allow for the potential for
lots of Notes! - the vertical depth would adjust
automatically depending on how much text was within a
particular Notes record.
It sounds as if your problem is that the subforms data
source isn't gathering the data you expect to be displayed
(?) In which case you need to look at the query/table
behind the form/subform and also how the subform/form are
linked.

Hope this is of some help to you.

Regards,

Lee
 
Lee said:
Not sure if this is any help but...

The CanGrow and CanShrink property only allows controls
(within the detail section) of a form/subform to display
more of the data for a SINGLE record. So if you have
a 'Notes' field for example, you don't have to set the
control to 3 inches deep to allow for the potential for
lots of Notes! - the vertical depth would adjust
automatically depending on how much text was within a
particular Notes record.

You're correct as far as you go, but you should add that it also only
applies to when the form is PRINTED. CanGrow has no affect on the form
when viewed on-screen.
 
I'm working with a form, I was hoping there was a way to
have the vertical depth change automatically.
 
frank said:
I have a main form that contains a sub form. The sub form
is a continuous form that has the Can Grow propery set to
yes. When the main form is displayed, the sub form is not
growing and showing all records in the sub form at once.
How do i get the sub form to grow for however many records
are in the sub form? Basically, the main form contains
data infront of and after the sub form so I need the sub
form to grow dynamically.


I think this code will give you a head start on your
problem.

Private Sub Form_Load()
Dim rs As Recordset
Dim lngDetailHgt As Long
Dim lngSfmHgt As Long
Const MAXHGT As Long = 6 * 1440

With Me.sfmListSub.Form
lngDetailHgt = .Section(0).Height
Set rs = .RecordsetClone
rs.MoveLast
lngSfmHgt = rs.RecordCount * lngDetailHgt _
+ .Section(1).Height _
+ .Section(2).Height
If lngSfmHgt > MAXHGT Then
lngSfmHgt = MAXHGT
End If
Me.InsideHeight = Me.sfmResizeSub.Top _
+ Me.Section(1).Height _
+ Me.Section(2).Height _
+ lngSfmHgt
Me.sfmResizeSub.Height = lngSfmHgt
End With
End Sub

I included terms for both the main form and subform head and
footer sections. If you don't have those sections remove
the respective terms from the expressions
 
Back
Top