• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 765
  • Last Modified:

Form/subform can grow/shrink.

I'm trying to come up with a form that will display data from several tables. I'll just display one record from the main table, but there may be several records from supporting tables. I usually use sub-forms for this type of situation, but in this case, I want the support records to display fully, without scrolling.

So, this is easy to do in a report, but since can grow/shrink doesn't work with forms, I'm just wondering if there are alternatives to accomplish what I want.

I've played around with changing the subtforms .height and .top properties (based on # of records) and can probably make it work that way, it just seems like a very large amount of code to handle about 6 or 7 subforms and other contronls that come between and after the subforms.
3 Solutions
jadedataMS Access Systems CreatorCommented:
Hey avoorheis!

  Your simple answer here is to set the subforms to a size that is most comfortable for all views of the data.
  And to segregate the subforms in such a ways that other controls don't interfere with "lengthening" the subform.
  Perhaps a Tab control for the subforms would serve this purpose.
tabs would work good as jack suggests, you might also consider making the height of the subforms as large as the screen will hold ...

Me.childForm1.Height = Me.InsideHeight - (Me.childForm1.Top + me.Section(acFooter).Height)

Mike EghtebasDatabase and Application DeveloperCommented:
Stack your subforms (all with 0 heigt) very closely in top of one another in detail section of your main form, like:
=================================================    sf1    continous
=================================================    sf2    continous
=================================================    2f3    continous

In the on openevent of you form include
Dim Qty1 As Integer, Qty2 As Integer, Qty3 As Integer
Qty1 =Dcount("*","Table_sf1","add your criteria here")
Qty2 =Dcount("*","Table_sf2","add your criteria here")
Qty3 =Dcount("*","Table_sf3","add your criteria here")
Me!sf1.Height=1.667*1440*Qty1     ' you may need to add a constant correction value to this
Me!sf2.Height=1.667*1440*Qty2     ' you need to experiment with it
Me!sf3.Height=1.667*1440*Qty3     ' 1.667" is defaul value.  I usually change it to .15"

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

avoorheisAuthor Commented:

I tried your suggestion, but the first subform covers up the second subform. Are you saying that the subforms after the first one actually move lower on the form (depending on the height of subforms that come before them)?
Mike EghtebasDatabase and Application DeveloperCommented:
Sorry about it, use:

Dim Qty1 As Integer, Qty2 As Integer, Qty3 As Integer
Qty1 =Dcount("*","Table_sf1","add your criteria here")
Qty2 =Dcount("*","Table_sf2","add your criteria here")
Qty3 =Dcount("*","Table_sf3","add your criteria here")

avoorheisAuthor Commented:
thanks guys
I guess there really isn't some magical way to make a sub form act like a report, but your suggestions will help.

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now