473,378 Members | 1,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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!

Nov 13 '05 #1
7 4505
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
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
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
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

354
by: Montrose... | last post by:
After working in c# for a year, the only conclusion I can come to is that I wish I knew c. All I need is Linux, the gnu c compiler and I can do anything. Web services are just open sockets...
1
by: Shiz | last post by:
I currently have a Form with Option buttons (to give you the option of sorting by name, or by Field, etc), these are referenced in a module which then formats the report contingent on the option...
11
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity...
7
by: SueB | last post by:
Greetings. I have a report based on the following query (hang in there ... it's quite long): SELECT Year(.) AS Yr, tblEvents.eventID, tblEvents.eventname, tblEvents.eventhost,...
3
by: gardner | last post by:
Please help. I am trying to count something in a Group Footer using a Text Box. If what I am doing is not doable, or there is a better way to structure this please tell me. Here is the situation:...
28
by: Wladimir Borsov | last post by:
The HTML source of one of my web pages starts simplified with a code like: ---- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> ..... <BODY BACKGROUND="images/myback.gif"> <div...
1
by: PDH | last post by:
I have sumation in my group footer that I would like to hide when the sumation = zero. I am relatively new to MS access and my current attempt involved the onformat and the following expression: ...
0
by: gnewsgroup | last post by:
Well, I am trying to use the footer row of a GridView for insertion purpose. There are some articles about this, for example, the gridviewguy.com has an example, which always displays the footer...
3
by: carmela_wong | last post by:
I am trying to output a report in which I show the total number of people if groupfooter is "STAFF" but not if it is "ATTENDEES". The report will say: STAFF: Staff1....... Staff2...... Total...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.