By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!

Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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!

Nov 13 '05 #2

P: n/a
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" <go****@darincline.com> 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!


Nov 13 '05 #3

P: n/a
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!

Nov 13 '05 #4

P: n/a
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
go****@darincline.com 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!

Nov 13 '05 #5

P: n/a
On 28 Aug 2005 07:02:38 -0700, go****@darincline.com 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


No - that's not true. The report footer's sum (using a Sum([<fieldname>]) has
the correct total sum value when examined from within groups. It is not a
partial sum depending on where you are in the report when you read it.

Nov 13 '05 #6

P: n/a
"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!

Nov 13 '05 #7

P: n/a
On 30 Aug 2005 05:57:18 -0700, go****@darincline.com wrote:
"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!


You can use hidden count fields [ =Count(*) ] then, instead of SUM. This will
solve the problem with zero sums.
Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.