Controlling form size

mkdrep

Registered User.
Local time
Today, 03:42
Joined
Feb 6, 2014
Messages
181
I have one form "Products" that I have a button on which opens up another form. The second form lists a different number of lines depending on how many items are in a group.

The problem I am having is that I can not make the second form shrink or grow depending on how many line items I have in each group. Currently, I have to make the form as large as the most possible lines I could have (which is 19) but sometimes I might only have 5 lines in a form.

Any suggestions as to how I might make this happen would be greatly appreciated.

Thanks in advance...Mark
 
Are you aware of the InsideHeight and InsideWidth properties of a form? Maybe you can determine that one line is 0.25 inches high, so then you can do math like . . .
Code:
Me.InsideHeight = 0.25 * 1440 * NumberOfLines
Note that the InsideHeight property of a form is expressed in twips, of which there are 1440 in an inch.
 
Thank you for your reply. Maybe I did not explain things well the first time. I have attached (2) jpegs that show the form in Design View (DV) and Normal View (NV).

I guess what I am trying to accomplish would be similar to developing a report that would increase or decrease in size depending on how many "detail" lines there are in a report.

To me, the (DV) of the form looks very similar to a report so I would expect the number of lines show to change depending on how many detail lines there are. The resulting (NV) of the form only shows (6) Access Grp A3A lines, when there should actually be (9) A3A line showing.

My question is how do I get the form to only show the exact number of detail lines for each respective Access Grp.

Thanks again for the help.
 

Attachments

  • Accessories-DV.jpg
    Accessories-DV.jpg
    71.1 KB · Views: 164
  • Accessories-NV.jpg
    Accessories-NV.jpg
    51.9 KB · Views: 109
I think you are thinking of the cangrow function but this only applies to controls and only when printing

Mark's solution is correct although I would suggest a variation as

recordsetclone.movelast
DoCmd.MoveSize(, , , section(1).height+(section(0).height*me.count))

you may need to add in additional height factors if you are displaying the horizontal scrollbars and/or navigation bar

Put this code in the form load event
 
.InsideHeight will include also the Header and Footer.
You only need to change the Details section height
 
calculation is very simple.
Check your detail size (you create it for a single record) and double it with the number of records you want to see.
it's 1440 twips per inch and 567 twips per cm.
For this add the heights of the Header and Footer.
Set all as the .InsideHeight

if the detail size is 1.2 cm and you want to have 20 records:
Me.InsideHeight = 1.2 * 567 * 20 + Me.Section("Header").Height + Me.Section("Footer").Height

As the form size need to be changed based on number of records you don't need to take care the size of other elements (Bars, Navigation buttons, border...) you only need to set the max number of records that will make the MAX size of form.

You can also hide the side bar if the number of records did not exceed the Max form's size.
 

Users who are viewing this thread

Back
Top Bottom