is there now way to have the subform auto resize the detail section to match the number of records?
you need to set the height to
the height of the header+the height of the footer+(the height of the detail section x the number of records)
suggest use the resize event or current event - all depends on how your form actually works
seem to recall you may need a small adjustment because you also need to account for the subform border size as well
so in the main form current event you might have something like
mysubform.height=mysubform.form.section(1).height+ mysubform.form.section(2).height+(mysubform.form.s ection(0).height*mysubform.form.recordset.recordco unt)
you will need additional code to trap errors - if the height +subform top is too great because of the number of records you will get an error. Or perhaps when the code is run, the subform has not been fully populated with records. As I said, depends how your form is intended to work.
Personally, in design view you can simply adjust the subform control height so it displays full rows then you have the scrollbar if there are more rows. It is dangerous to assume 'there will never be more than X records' because at some point, there will be. Also from a user perspective, having a control keep changing size can be disconcerting.
What I have done in the past where a client want to be able to resize is to put a bar just below the subform and use the mousedown/move/up events to resize the the subform - it gives them control.
code would be something like this - hbar is a box control set with a height of 30 twips (0.05cm)
Code:
Dim startY As Single
Dim mseDown As Boolean
Const Margin = 30
Private Sub hBar_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mseDown = True
startY = Y
End Sub
Private Sub hBar_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next 'in case form sizing parameters are breached
If mseDown And hBar.Top + Y - startY > sform.Top And hBar.Top + hBar.Height + Y - startY + Margin < InsideHeight Then 'within sizing parameters
'move the bar
hBar.Top = hBar.Top + Y - startY
'adjust subform height
sform.Height = hBar.Top - sform.Top - Margin
End If
End Sub
Private Sub hBar_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
mseDown = False
End Sub