Autosize an embedded subform

Tskutnik

Registered User.
Local time
Today, 15:30
Joined
Sep 15, 2012
Messages
234
All - any help on this one would be appreciated

In a master form (Form1) I have an embedded subform (Subform1). The subform will add records (rows) over time, so the height of the subform will of course grow. Right now the Form1 row height where Subform1 sits is fixed, I had to make the height much larger than is needed to accommodate the upcoming growth.

I'd like the Form1 row height to automatically change as needed based on the size of the Subform.... So as Subform1 grows, so does the Form1 row height.

I'm not a coder, so if there is a code-based solution the more specific you could be the better.

Thanks
Tony
 
Wouldn't it be better to set up the form(s) for the maximum size and then add vertical scroll bar in the subform to accommodate additional rows that go beyond the visible area?
 
I agree with sxschech - at some point the number of records to be displayed will exceed the maximum height allowed for a form - which in itself is taller than most monitors. Better to manage the size of the subform based on the size of the form - which in turn should be smaller or same size of the monitor.

To do this in the mainform resize event put

mysubformcontrol.height=insideheight-mysubformcontrol.top

this assumes that your main form is a single form without header or footer. If you are using headers and footers it will need further adjustment for the heights of these two sections.

But if you want do it your way your subform will need to be a continuous form and the subform control height will be

height of subform header+height of subform footer+(height of subform detail* number of records+1 if allow additions is true)

if your subform is a datasheet, the best you can do is try to determine the row height by trial and error - it varies automatically depend on font, font size/bold etc)
 

Users who are viewing this thread

Back
Top Bottom