PC Review


Reply
Thread Tools Rate Thread

Automatically resize subform height based on number of returned re

 
 
Stacie2410
Guest
Posts: n/a
 
      20th Jan 2010
I have a main form that has a subform on it. The subform is displayed in
Continuous Forms view. In the footer of the subform, I have a field that
gives a sum of one of the columns on the form, for the records returned. It's
set up to kinda look like a table, with the bottom line being the total of
column C. This all works just fine. However, my problem is that sometimes
there may only be one record returned, and sometimes there could be 10
records. The subform size doesn't change if there's 1 record or if there's
10 records...the footer stays in the same place, but say there's only 1
record returned, there will be a large gap of space between the 1 record, and
my "total line".

Is there a way to automatically resize the entire subform depending on how
many records are returned, so that the footer (which has my totals line), is
always right underneath the records which are returned?

Another problem with this, is that there's more data on the form that's
further down after the subform...If there are many records, you don't notice
the gap, but if there aren't many records on the subform, the next section
looks like it's way down on the form, with a large blank area in between it
and the subform above it.

Is there a way to change this?
 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      20th Jan 2010
Stacie2410 wrote:

>I have a main form that has a subform on it. The subform is displayed in
>Continuous Forms view. In the footer of the subform, I have a field that
>gives a sum of one of the columns on the form, for the records returned. It's
>set up to kinda look like a table, with the bottom line being the total of
>column C. This all works just fine. However, my problem is that sometimes
>there may only be one record returned, and sometimes there could be 10
>records. The subform size doesn't change if there's 1 record or if there's
>10 records...the footer stays in the same place, but say there's only 1
>record returned, there will be a large gap of space between the 1 record, and
>my "total line".
>
>Is there a way to automatically resize the entire subform depending on how
>many records are returned, so that the footer (which has my totals line), is
>always right underneath the records which are returned?
>
>Another problem with this, is that there's more data on the form that's
>further down after the subform...If there are many records, you don't notice
>the gap, but if there aren't many records on the subform, the next section
>looks like it's way down on the form, with a large blank area in between it
>and the subform above it.



In the subform's Load event (or later or in the main form),
you can use code along these lines:

Const MaxRecs As Integer = 10
Dim NumRecs As Integer
With Me 'code in subform
'With Me.subformcontrol.Form 'code in main form
.RecordsetClone.MoveLast
NumRecs = .RecordsetClone.RecordCount
If NumRecs > MaxRecs Then NumRecs = MaxRecs
.InsideHeight = .Section(1).Height + .Section(2).Height _
+ NumRecs * .Section(0).Height
End With

Make sure the main form section with the subform is tall
enough for the MaxRecs size of the subform or will get an
error.

--
Marsh
MVP [MS Access]
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to resize label height automatically. ngreplies Microsoft VB .NET 1 15th Feb 2006 10:28 AM
automatically adjust subform height based on amount of records =?Utf-8?B?QW5kcmV3?= Microsoft Access Forms 7 13th Jan 2006 03:17 PM
Set a SubForm to resize (vertically) based on the number of record =?Utf-8?B?SUx1dkFjY2Vzcw==?= Microsoft Access 1 29th Dec 2005 04:48 PM
What is the trick to make rows resize height automatically? =?Utf-8?B?R3VtYnk=?= Microsoft Excel Misc 3 13th Jul 2005 07:12 PM
Resize height only of form/subform depending on screen resolution kevinhay Microsoft Access Forms 3 12th May 2004 04:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:25 PM.