sizing subforms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello
i have a form that has three subforms. i would like to automatically resize
the subforms so that there is no empty space around the edges.

currently, if i only have one row of data, there is empty space below the
row. if i don't resize the form on the right side, there is empty ugly space
on the right.

i can resize the form manually, but it never works totally. is there a way
to have the subform fit automatically on the main form without any grey areas
showing.

i have looked for the answer, but either no one finds this important, or it
is so simple that no one thought to ask.
thanks for any help.
 
Bernard,

I am not sure about the problem with the horizontal size. Isn't the
width of the subform always the same, regardless of the number of
records or amount of data? So you just need to size the width of the
subform control on the main form appropriately.

As for the height of the subform, this can be adjusted in code. As an
example, let's suppose you have a continuous view subform, with a header
which is 1cm high, and the detal section of the form is 0.6cm high. And
lets say you have enough space on your main form to see 12 records on
the subform. Then on the Load event or the Curren6t event of the main
form, you could do something like this...

Dim subHeight As Integer
Dim subRecords As Integer
subRecords = DCount("*", "SubformQuery", "[ID]=" & Me.ID)
subHeight = Int(((0.6 * subRecords) + 1) * 567) ' (567 twips per cm)
If subHeight > 4650 Then
subHeight = 4650 'enough for 12 records
End If
Me.MySubform.Height = subHeight
 
.... of course, this is just an example to give the concept. There are
other considerations which you would need, for example, if you were
using the subform for data entry, in which case you need to allow space
for the blank new record row in the subform, and also use similar code
to adjust the height of the subform when a new record is added, etc.
 
Back
Top