Dynamically sizing subforms

rapted

New member
Local time
Today, 18:52
Joined
Dec 13, 2007
Messages
2
Hi all, have searched for this but could not find an answer to fit my problem.

Let's say there is a simple form with header and footer visible. The header has only a label, the footer has some command buttons and on the detail section, we have a combo that finds records based on a table 1. Table 1 is 1 to many related to another table 2. On the form detail, we have a subform based on table 2.

All simple by now. Is there a way to dynamically fit the records on the subform so that the form footer is not sent down. I mean, if there are only two records on the sub matching the selection of the combo box on the main, the subform is sized accordingly so that the buttons on the footer of the main show right below and if there are more than x records on the sub which will cause the main form to scroll, only then to have a scrollbar on the sub..

I'm not sure, but hope I can make it further clear

Best, raptor
 
Something like this:
Code:
Dim NumRecords as Long 'Or Integer, Byte, whatever fits your data
Const RowHeight as Integer = 100 'Change to fit your needs
Dim SubformHeight as Integer
Const MaxSubformHeight as Integer = 2000 'Change to fit your needs

NumRecords = Me.MySubform.Form.RecordsetClone.RecordCount
SubformHeight = NumRecords * RowHeight
If SubformHeight > MaxSubformHeight Then SubformHeight = MaxSubformHeight
Me.MySubform.Height = SubformHeight
 

Users who are viewing this thread

Back
Top Bottom