Subform can grow

I have a continuous subform in a single form main form. I am trying to get the subform to grow or shrink depending the size of the subform when populated I have everything that I can see set to cangrow yes and canshrink yes, but it will not size according to number of records in subform.

Am I trying to do something that cannot be done?
Derek BrownMDAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
you can use the resize event of the subform to figure out the height of the subform based on the number of records to display.

private sub form_resize()
me.insideheight=me.recordsetclone.recordcount * me.section(acdetail).height

end sub

basically that is how the code to look like to expand/contract the subform height
if headers and footers are used, you need to add their height to the equation

Controls on forms are not resizable except by your own code.  Although newer versions of Access have some ability to size objects using anchoring.  This is code I use in the MAIN form to resize the subform when the main form is resized.  This is particularly useful when you have a subform in datasheet view.

To use this code, substitute your own subform name and play with the padding values.  What you need will depend on the height of the header and footer of the main form.
Private Sub Form_Resize()
    Const LeftRightPadding = (0.125 + 0.25) * 1440
    Const TopBottomPadding = (0.65 + 0.375) * 1440
    Me.sfrmClient.Height = Me.InsideHeight - TopBottomPadding
    Me.sfrmClient.Width = Me.InsideWidth - LeftRightPadding
End Sub

Open in new window

Controls on reports are automatically sizable (vertically) as long as you have the can grow/can shrink properties set for the controls and the sections that hold them.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Derek BrownMDAuthor Commented:
Thanks both

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.