Dynamically Size Form

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

Guest

I have a main form with 37 subforms embedded, with visible set to No. I have
checkboxes that, when checked, set the Visible property to True. (Used for
data entry - when an entry affects a department, that department checkbox is
selected, showing the subform for entry.)

Is is possible to dynamically size the form to be only long enough to show
the visible subforms? (Obviously, if it is I'd really appreciate a clue as to
how to do it ;-)

Thanks in advance
 
FlyBoy said:
I have a main form with 37 subforms embedded, with visible set to No. I have
checkboxes that, when checked, set the Visible property to True. (Used for
data entry - when an entry affects a department, that department checkbox is
selected, showing the subform for entry.)

Is is possible to dynamically size the form to be only long enough to show
the visible subforms? (Obviously, if it is I'd really appreciate a clue as to
how to do it ;-)


Assuming you know which visible subform control is nearest
the bottom of the main form, you can adjust the mainform's
height this way:

Me.InsideHeight =Me.lowestsubform.Top + _
Me.lowestsubform.Height + _
Me.Section(1).Height + Me.Section(2).Height

If the main form does not have it's form header/footer
sections, leave out the section 1 and 2 terms.
 
If you do this right, you will only need one subform control on the page.
Then, as the user select the department (I'd put these in a combo box instead
of a series of checkboxes), you would change the sourceobject of the subform
control to whichever subform you want them to fill in.

HTH
Dale
 
I wish.

Sadly, I'm contracting with a client who dictates the appearance of the
forms. I've tried explaining the usability and functionality aspects.

Thanks Dale.
 
Marshall:

Thanks for getting me thinking outside the box. While this won't get me
where I need to be (if the first and last subforms are the only ones
selected, the form will still be full length with a huge gap in between the
subs), it puts me on the right track. Surely there's a way to use the Visible
property as a test and then programmatically move the subs to arrange them
and size the form.

I'll post the code here if I figure it out.

Thanks again.
 
FlyBoy said:
Thanks for getting me thinking outside the box. While this won't get me
where I need to be (if the first and last subforms are the only ones
selected, the form will still be full length with a huge gap in between the
subs), it puts me on the right track. Surely there's a way to use the Visible
property as a test and then programmatically move the subs to arrange them
and size the form.

Don't wrack your brain too hard on this issue. Aside from
the issue of the form size jumping around (dazling the users
into a stunned state ;-)), just loop through the form's
controls setting the visible one's Top property before
setting the form's inside height.

Const clngSpacing As Long = 300
lngCurTop = somevalue
For Each ctl In Me.Section(0).Controls
If ctl.ControlType = acSubForm Then
If ctl.Visible Then
ctl.Top = lngCurTop
lngCurTop = lngCurTop + ctl.Height + clngSpacing
End If
End If
Next ctl
Me.InsideHeight = lngCurTop ' + head and footer height
 
FlyBoy said:
Marshall:

Thanks for getting me thinking outside the box. While this won't get me
where I need to be

By the way, any reason why you don't consider using ONE sub-form control?

You an set what form a sub-form control displays. So, you have some combo
box, or code that selects what form you want to display and then you go:

strFormToShow = "frmSub1"
me.MyCoolSubForm.SourceObject = strFormToShow

In other words, at runtime, you can set the value of what form the sub-form
control will displays...

The above might not help...but I remember when someone told me this trick in
this very newsgroup..and it help me a lot!!
 
If you do this right, you will only need one subform control on the page.
Then, as the user select the department (I'd put these in a combo box
instead
of a series of checkboxes), you would change the sourceobject of the
subform
control to whichever subform you want them to fill in.

HTH
Dale

Great suggestion...and I just posted the exact same suggestion.....(next
time I will read all responses..and save myself some time!!).
 
Albert said:
By the way, any reason why you don't consider using ONE sub-form control?

You an set what form a sub-form control displays. So, you have some combo
box, or code that selects what form you want to display and then you go:

strFormToShow = "frmSub1"
me.MyCoolSubForm.SourceObject = strFormToShow

In other words, at runtime, you can set the value of what form the sub-form
control will displays...

The above might not help...but I remember when someone told me this trick in
this very newsgroup..and it help me a lot!!


A very useful idea in the right situation, but I understoof
FlyBoy wanted to display all the subforms releated to the
checked check boxes.
 
For the record, the client, NOT FlyBoy, wanted the subforms displayed! ;-)

Marshall, thanks a million. I hardly expected you to provide me with a cut
and paste solution the way you did.

You, and all the other contributors, probably don't appreciate how much we
hacks appreciate what you do for us. All of you save us untold hours of trial
and error with your laser guided solutions.

Rest assured there is a special place in heaven for you folks!
 
What a nice thing to say FlyBoy. Your kind comments go a
long way towards making all our efforts worthwhile.
 
Back
Top