Resize sub forms using vba - no top property

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

Guest

Access 2000 SP3

I'd like to change the size and position of a sub form which is on the
detail section of a "single form" form.

I've done this before with just rtf2 controls, but not sub forms.

I have a single form layout, which contains 1 subform taking up the left
side of a landscape A4 sheet, the right hand side is split in two
horizontally, 1 being another subform, the other being an RTF2 control.

Landscape A4
---------------------------
| sub2 |
sub1 |------------|
| rtf2 |
---------------------------

As before, I'd like to use the OnCurrent even to set the TOP and height of
the left and sub form. Then use the TOP+HEIGHT of the sub1 - HEIGHT of the
sub2 control to work out the TOP of RT2 etc etc

I have done this before with RTF2 controls, promise, but the subforms don't
appear to have the TOP property.

How can I control the height of subforms and then also read in these
paramaters such as HEIGHT and TOP to help me set the sizes of the other
controls to allow for data size changes, and keep a uniformed look.

Many thanks for any help!
Steve'o
 
Steve'o said:
Access 2000 SP3

I'd like to change the size and position of a sub form which is on the
detail section of a "single form" form.

I've done this before with just rtf2 controls, but not sub forms.

I have a single form layout, which contains 1 subform taking up the left
side of a landscape A4 sheet, the right hand side is split in two
horizontally, 1 being another subform, the other being an RTF2 control.

Landscape A4
---------------------------
| sub2 |
sub1 |------------|
| rtf2 |
---------------------------

As before, I'd like to use the OnCurrent even to set the TOP and height of
the left and sub form. Then use the TOP+HEIGHT of the sub1 - HEIGHT of the
sub2 control to work out the TOP of RT2 etc etc

I have done this before with RTF2 controls, promise, but the subforms don't
appear to have the TOP property.

How can I control the height of subforms and then also read in these
paramaters such as HEIGHT and TOP to help me set the sizes of the other
controls to allow for data size changes, and keep a uniformed look.


The position and amount of space used by the subform is
specified in the subform **control** on the main form. Note
that the name of the subform control might be different from
the name of the form object is is displaying.

The size of the controls in the subform is specified in each
control's properties.
 
Many thanks Marshall, I did not realise that the subform was (my words) a
kind of wrapper for another form, wrapper = control. So I had mistakenly set
the name of the control to be the same as the subform, doh!

This brings me to a small question, to resize the subform I need to know
what its current physical size is (to calculate the start), and then whats
its internal data physical size is ie what size it needs to be to display
everything.

With the RTF control from Stephen Lebans this was easy, the .height was the
property for the box height, and the .rtf2height was the property for the
data (still size demensions, not datatype size). So it was easy to compare
and then, if applicable, increase/decrease the .height to match the
..rtf2height.

This works well, is there a similar property for normal subforms. ie Can I
read in and change the control.height based on the size of the data in the
form.insideheight, or form.windowheight?

The help sais:
You can use the InsideHeight and InsideWidth properties to determine the
height and width (in twips) of the window containing a form.

You can use the Height and Width properties to size an object to specific
dimensions. This can be useful, for example, if you want to create objects
that are exactly the same size or that have the same width or height.

But this is confusing to me, am I looking at the wrong thing? Could you
post back with which is which, or if there is a better / another way?

Many thanks for any help.
Steve'o
 
Steve'o said:
Many thanks Marshall, I did not realise that the subform was (my words) a
kind of wrapper for another form, wrapper = control. So I had mistakenly set
the name of the control to be the same as the subform, doh!

This brings me to a small question, to resize the subform I need to know
what its current physical size is (to calculate the start), and then whats
its internal data physical size is ie what size it needs to be to display
everything.

With the RTF control from Stephen Lebans this was easy, the .height was the
property for the box height, and the .rtf2height was the property for the
data (still size demensions, not datatype size). So it was easy to compare
and then, if applicable, increase/decrease the .height to match the
.rtf2height.

This works well, is there a similar property for normal subforms. ie Can I
read in and change the control.height based on the size of the data in the
form.insideheight, or form.windowheight?

The help sais:
You can use the InsideHeight and InsideWidth properties to determine the
height and width (in twips) of the window containing a form.

You can use the Height and Width properties to size an object to specific
dimensions. This can be useful, for example, if you want to create objects
that are exactly the same size or that have the same width or height.

But this is confusing to me, am I looking at the wrong thing? Could you
post back with which is which, or if there is a better / another way?


I think you've lost me here. Without more information,
about I can say at this point is that a form's height is
described by the sum of its Header, Footer and Detail
sections. However, it the form is displayed in Continuous
(or Datasheet) View, it will probably diplaying multiple
detail sections, which brings the InsideHeight property into
play.

So, I think you need to determine the height of the form in
the subform and set the height of the subform control to
accomodate it.

This is just a wild guess at what you are trying to do based
on the case where the form in the subform control is being
displayed in Continuous View. I think you said you want to
do this in the main form's Current event:

With Me.subformcontrolname.Form
lngHgt = .Section(1).Height _
+ .Section(2).Height _
+ .RecordCount * .Section(0).Height
End With
Me.subformcontrolname.Height = lngHgt
 
Thanks again Marshall, apologies for my incoherent reply and thanks for
interpreting it correctly :)

The main form is single form view, the two sub forms are continuous (even
though Access sais this won't work, it does).

The other object on the main form is a RTF2 box from Stephen Labans, which
has two properties:
..height (the physical size of the box)
..rtfheight (the physical size of the box needed to show all the data)

These two properties are very useful in dynamically resizing the objects
using the onCurrent event.

I would like to be able to do a similar thing with the subform objects,
resize them dynamically based on the amount of physical space they need
rather than what they have.

The reason I'm not simply using CanShrink/Grow is because I also need to
keep ONE main form record and ALL its associated subRecords per page, ie
dynamically resize the objects to keep a uniformed appearance and never take
a record onto more than one page.

I hope that was a better explanation and less waffle this time :)

Your recordcount * detail section height etc calculation appears to be
exactly what I'm after to get the equivalent of the .rtf2height property.

Originally I was just wondering if there was a property which already had
this information, but from what you've said, the answer is no. So many
thanks for calculation, I shall go away and let you know how I get on, thanks
again!

Steve'o
 
Thanks Marshall, worked a treat :)

I'm using Access 2000 and had to change the recordcount bit to get it to work:

+ .Recordset.RecordCount * .Section(0).Height

Thanks again!
 
Steve'o said:
Thanks Marshall, worked a treat :)

I'm using Access 2000 and had to change the recordcount bit to get it to work:

+ .Recordset.RecordCount * .Section(0).Height


Correct, if I hadn't left that part out, I would have used
..RecordsetClone (out ot habit), but, in newer versions of
Access, .Recordset is just as good and maybe even a little
faster.
 
Back
Top