I use VBA to adjust the height of a continuous subform based on # of records, but my subform only adjusts to show up to 3 at a time w/ scrollbar (3 Viewers)

diamondDog

New member
Local time
Today, 12:28
Joined
Sep 18, 2024
Messages
7
How can I have my continuous form always expand to see all records instead of having a scroll wheel?

The following code seems to work well when I have up to three records, but any more than three records and the subform no longer grows but only displays a vertical scroll bar. How can I eliminate a vertical scrollbar to help force the resize of my subform to always show all records. I do not want any scrolling.

Code:
Private Sub Form_Current()

With Me.subform
    .Height = .Form.Section(1).Height + .Form.Section(2).Height + (.Form.Section(0).Height * .Form.Recordset.RecordCount)
End With

End Sub
 
You probably will have to adjust the subform container control's height as well and possibly the .InsideHeight of the parent form too.
 
Thanks for the response! I am a noob and found my code online. How would I implement your suggestions? Are these settings in the Property Sheet for my subform or would I have to add more VBA code?
 
I would create long number variable to store the result of your height calculation and then use
? Debug.Print lngNewHeight

You can also set a breakpoint in your code to review the values.
 

Users who are viewing this thread

Back
Top Bottom