Link to home
Start Free TrialLog in
Avatar of Mik Mak
Mik Mak

asked on

Calculate group footer height on Access report

How can I calculate the vertical size available for a Group footer, on a report, when considering the space used for page header, details and Group headers (and leaving room for the page footer also) on an access report ?
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Assuming I've understood this correctly, look at the sections height.

 If it has cangrow or canshrink set to yes, then all bets are off.

Jim.
I took that the wrong way after re-reading it.   You'd add the heights of all the sections except for the group footer, and subtract that from the page size along with the margins.

and of course if anything has cangrow and canshrink are yes, then all bets are off.

Jim.
Avatar of Mik Mak
Mik Mak

ASKER

Detail section can grow - so no way to do it ?
Not at design time.   At run time you can check where you are on the page, but not at design time.

Jim.
Avatar of Mik Mak

ASKER

So available space could be checked on the Group Footer On Print ?
:) Michael
What  is it that your trying to achieve or what problem are you having?

Jim.
Avatar of Mik Mak

ASKER

The problem is that the user wants a "nice" rectangle surrounding the information - and have specified it should fill most of the A4 page. So I have made a function that makes the vertical lines grow together with the detail height - but I'm missing a function to make vertical lines on the "remaining " blank space on the page - this I was hoping to put into a Group footer until it meets the page foorter where the bottom horizontal line would be (sorry English ius not my primary language, if there's any confusion :)
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way, here's an example of drawing some lines in the OnPage event:

Private Sub Report_Page()

10        Me.DrawWidth = 12
20        Me.Line (Me.linCol1.left, lngTop)-(Me.linCol1.left, lngEnd)
30        Me.Line (Me.linCol2.left, lngTop)-(Me.linCol2.left, lngEnd)
40        Me.Line (Me.linCol3.left, lngTop)-(Me.linCol3.left, lngEnd)

End Sub

 What I do to make it easy is to place some line controls where I want lines to start and end in a section.  I draw one horizontal line in the page header and footer, and then place controls for the columns as well (in the case, linCol1, 2, and 3).  Then I pickup the horizontal positions when the sections are printed:

Private Sub PageHeader_Print(Cancel As Integer, PrintCount As Integer)

10        lngTop = Me.Line27.top + (Me.Line27.BorderWidth * 20)

End Sub

Private Sub PageFooter_Print(Cancel As Integer, PrintCount As Integer)

10        lngEnd = Me.top

End Sub

This allows you to draw a grid.

Jim.
Avatar of Mik Mak

ASKER

Thank you for your patience Jim :)

Please tell me more on how this could be done using method 1)
and I should have also mentioned that:

 Me.Top and Me.Left is the current position on the page when your executing.  

Jim.
Avatar of Mik Mak

ASKER

So,when looking at your code - no code is handling the Group footer where the left/right lines should confine the empty Space ? Do you place linColx on the Group footer then ?
Avatar of Mik Mak

ASKER

I've just played with the Me.MoveLayout = False option - thats brilliant - that does open up a whole new level of possibilites  as you also mention on the link :) Thank you very much for that tip ! :)
Avatar of Mik Mak

ASKER

But how do you make the underlying section high enough to cover the whole page height - but not so high that you get this error ?
2019-01-21_17-20-52.jpg
The example I gave is drawing lines from the bottom of the page header to the top of the page footer.

The column controls (linCol1, 2, and 3) are just being used so it is easy to get the left position for each and I included them in the page header.   For example, in my page header I would have:

A-------------------------------B-------------------------------------C

Where A, B, and C are the column controls and where I want vertical lines.  They do not do anything other than act as place holders so I do not have to do the math (lines are done in twips, not inches - there are 1440 twips to an inch).  If I need / more or less columns, then I add or remove as needed.  Here it is two columns with A and C forming the sides of the box.  

By doing that, when it comes to drawing the lines, I can just do:

20        Me.Line (Me.linCol1.left, lngTop)-(Me.linCol1.left, lngEnd)

 This technique should work fine as well for drawing lines between a group header and footer.

Jim.
I've just played with the Me.MoveLayout = False option - thats brilliant - that does open up a whole new level of possibilites  as you also mention on the link :) Thank you very much for that tip ! :)

 yes it does.  

But how do you make the underlying section high enough to cover the whole page height - but not so high that you get this error ?

 It depends on the form your trying to do. Sometimes you need to repeat the grid in the page footer and get it to line up, which is not clear from the article.   Other times it works fine without issue.  Here's a packing slip report I did recently:

User generated image
User generated image
and what it looks like:

User generated image
 and that worked fine because there was no overlap between the header + detail and the page footer.

Jim.
Avatar of Mik Mak

ASKER

Thank you very much Jim, but I'm pursuing the underlying method instead :) - only problem I have is that I can't make the page header tall enough for the lines to meet at the bottom - if I make it any higher I get the aforementioned error  - and my total height of top/bottom margins, page header and page footer is only 28.7 - which is exactly the 1 cm short I miss on the lines :) ?
Avatar of Mik Mak

ASKER

Think we where typing at the same time :) - but if I put some of the grid in the footer I just get the error again
You should be able to get them to meet.

Just size the page header enough to the point where it would just meet the page footer.  The bottom of the form then would be in the page footer.  So (page size - top margin - bottom margin - page header) = max size of footer.  Footer will need to be slightly smaller than this.

I have to say, when I want to span an entire page with a box, header to footer, I always use method #1.

When I need to do something special, like the Home Depot packing slip where text flows down along side the detail and it spans the header and/or footer along with the detail, then I use method #2.  #2 always takes some adjustments though to get it to work.

Jim.
Avatar of Mik Mak

ASKER

I'm nearly there - it's a bit fiddly :) But now it's only displaying my righthand line/edge on the first page - it's invisible on the rest of the page ?
Avatar of Mik Mak

ASKER

ok it needed a 0.01 adjustment to be visible - pretty strange :)
Avatar of Mik Mak

ASKER

Thank you so much for your help and patience - very much appreciated ! Have a nice day
Glad to hear your set.

Jim.