A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do i hide a group footer if it's the only group?



 
 
Thread Tools Display Modes
  #1  
Old August 28th, 2005, 02:39 AM
Darin
external usenet poster
 
Posts: n/a
Default How do i hide a group footer if it's the only group?

I have a report that sub-totals on a group, then grand-totals at the
report footer. If there's only one group, the sub-total and grand
total are redundant, so I only want to show one of them. I know how to
count the groups, then hide the report footer if there's only one
group, but my problem is I want to hide the group footer (sub-total),
not the report footer (because the report footer references what the
grand total is for, which is always necessary, while the group footer
references the sub-category that the sub-total is for, which isn't
necessary if there's only one sub-category).

The standard solution of getting a running count doesn't work, because
by the time it has reached the first group footer, the count is still
"1", since it hasn't gotten to the second group yet. The end result is
the group footer is shown from the 2nd group and on, but the first
group gets omitted.

Any ideas?

Thanks!

Ads
  #2  
Old August 28th, 2005, 03:40 AM
Steve Schapel
external usenet poster
 
Posts: n/a
Default

Darin,

You mentioned that you "know how to count the groups, then hide the
report footer if there's only one group", so... why can't you just do
the same thing, i.e. count the groups, and hide the group footer if
there's only one group? There are a number of ways you could "count the
groups" for the purpose of toggling the visibility of the group footer
section. One would be to open a recordset and get a count, for example...
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT DISTINCT GroupID FROM
YourQuery")
rst.MoveLast
Me.Section(6).Visible = rst.RecordCount 1

Another would be to make a query based on 'SELECT DISTINCT GroupID FROM
YourReportQuery' and then use this in your code...
Me.Section(6).Visible = DCount("*","YourGroupsQuery") 1

--
Steve Schapel, Microsoft Access MVP


Darin wrote:
I have a report that sub-totals on a group, then grand-totals at the
report footer. If there's only one group, the sub-total and grand
total are redundant, so I only want to show one of them. I know how to
count the groups, then hide the report footer if there's only one
group, but my problem is I want to hide the group footer (sub-total),
not the report footer (because the report footer references what the
grand total is for, which is always necessary, while the group footer
references the sub-category that the sub-total is for, which isn't
necessary if there's only one sub-category).

The standard solution of getting a running count doesn't work, because
by the time it has reached the first group footer, the count is still
"1", since it hasn't gotten to the second group yet. The end result is
the group footer is shown from the 2nd group and on, but the first
group gets omitted.

Any ideas?

Thanks!

  #3  
Old August 28th, 2005, 04:18 AM
Steve Jorgensen
external usenet poster
 
Posts: n/a
Default

If, say, the group total control is called txtGrpTotal and the grand total
control is called txtGrandTotal.

In this case, just set Format event handler for the group footer, and in that
procedure, say...

Cancel = (Me!txtGrpTotal = Me!txtGrandTotal)

On 27 Aug 2005 18:39:21 -0700, "Darin" wrote:

I have a report that sub-totals on a group, then grand-totals at the
report footer. If there's only one group, the sub-total and grand
total are redundant, so I only want to show one of them. I know how to
count the groups, then hide the report footer if there's only one
group, but my problem is I want to hide the group footer (sub-total),
not the report footer (because the report footer references what the
grand total is for, which is always necessary, while the group footer
references the sub-category that the sub-total is for, which isn't
necessary if there's only one sub-category).

The standard solution of getting a running count doesn't work, because
by the time it has reached the first group footer, the count is still
"1", since it hasn't gotten to the second group yet. The end result is
the group footer is shown from the 2nd group and on, but the first
group gets omitted.

Any ideas?

Thanks!


  #4  
Old August 28th, 2005, 03:02 PM
external usenet poster
 
Posts: n/a
Default

Thanks for the help guys! When I say "I know how to count the groups",
I meant in the more typical "easy" way of putting a text box in the
group header or footer that is = 1, with a running sum on it, then
setting the format event for the group to something like
"me.groupfooter.visible = me.groupcount 1". Sorry, should have
specified that from the start.

Anyway, Steve J, if I understand your solution correctly, it has the
same problem as the above one... the FIRST group footer gets hidden
even when there are multiple groups, because the subsequent groups
haven't yet been counted. That is my problem, I don't know an EASY way
to get a total group count BEFORE getting to the goup footer for the
first group. That's where Steve S.'s solution comes in, and I may have
to resort to that. It's just that the query that makes up the
recordset for this report is kind of complex, so the part where I would
"insert YourReportQuery" ends up bing a lot more hairy than it would
first appear. I've avoided that, because I thought it might be slow.
But I'll try it to see how it does.

Thanks!

  #5  
Old August 28th, 2005, 08:10 PM
Steve Schapel
external usenet poster
 
Posts: n/a
Default

Darin,

I understand about the data for the report being complex, and you
wouldn't need to necessarily follow my suggestion literally by directly
using the query that the report is based on. But I imagine you would be
able to make a query that returns you the number of groups that your
report will contain, and I can't see it is likely that it would be any
slower than the running of the report itself.

--
Steve Schapel, Microsoft Access MVP


wrote:
Thanks for the help guys! When I say "I know how to count the groups",
I meant in the more typical "easy" way of putting a text box in the
group header or footer that is = 1, with a running sum on it, then
setting the format event for the group to something like
"me.groupfooter.visible = me.groupcount 1". Sorry, should have
specified that from the start.

Anyway, Steve J, if I understand your solution correctly, it has the
same problem as the above one... the FIRST group footer gets hidden
even when there are multiple groups, because the subsequent groups
haven't yet been counted. That is my problem, I don't know an EASY way
to get a total group count BEFORE getting to the goup footer for the
first group. That's where Steve S.'s solution comes in, and I may have
to resort to that. It's just that the query that makes up the
recordset for this report is kind of complex, so the part where I would
"insert YourReportQuery" ends up bing a lot more hairy than it would
first appear. I've avoided that, because I thought it might be slow.
But I'll try it to see how it does.

Thanks!

  #7  
Old August 30th, 2005, 01:57 PM
[email protected]
external usenet poster
 
Posts: n/a
Default

"The report footer's sum (using a Sum([fieldname]) has
the correct total sum value when examined from within groups."

OH!! My bad. I thought you were saying to use the fields that are the
group conters, not the actual data fields. NOW I see what you are
saying, and yes, that works, and is simple! Thank you very much. The
only downside I can see to that is the very slight possibility of it
not working correctly under certain conditions (like a report with two
groups, one with a sub-total of 0, where the other group that has all
the money is the one that get's it's subtotal hidden). But those cases
in my application would be extremely rare. Even if that would be a
concern, I would think that a field could be added to the source query
that would simply be "1" AS "line count", then sum that (with invisible
controls), and use those totals and sub-totals instead of the real
values.

Thanks for your help!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Keep Together last record detail with group footer Craig Setting Up & Running Reports 1 May 18th, 2005 07:33 AM
Group footer has blank spaces PizzaBoy Setting Up & Running Reports 0 April 23rd, 2005 04:23 PM
(Leo) Page number footer for each group on reports Leo Setting Up & Running Reports 2 March 10th, 2005 06:29 AM
Conditional Group Footer landeye Setting Up & Running Reports 2 March 2nd, 2005 07:09 PM
Complicated display in group footer Jennifer Setting Up & Running Reports 6 June 1st, 2004 09:06 PM


All times are GMT +1. The time now is 06:02 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 OfficeFrustration.
The comments are property of their posters.