Set a SubForm to resize (vertically) based on the number of record

I

ILuvAccess

Can any advise me as to how I can set a subform (modal = Yes) to resize
vertically based on the number of records / rows are abvailable for view when
opened? I don't want the end user to have to use the vertical scroll bar
every time the sub form is opened.
 
R

Rick Brandt

ILuvAccess said:
Can any advise me as to how I can set a subform (modal = Yes) to
resize vertically based on the number of records / rows are
abvailable for view when opened? I don't want the end user to have to
use the vertical scroll bar every time the sub form is opened.

First a terminology correction. If you are "opening" this form then it is not a
subform. A subform is a form embedded within another using a subform control.
If you are opening a form pre-filtered on a value in another form then the form
might be described as a "related", "linked", or "synchronized", but it is not a
subform.

You would need to know how many "twips" are required for each record and then in
the load event you would get the record count and then set the size of the form
window based on that.

Dim RecCnt As Integer

RecCnt = Me.RecordsetClone.RecordCount

Me.InsideHeight = RecCnt * SomeValue

The above is over-simplified. You would likely need a base amount that you
would set the form height to even if zero records are found and you might want
to use an If-Then block to prevent the size from going over a maximum size.
 
Top