473,836 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4547
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.OpenR ecordset("SELEC T DISTINCT GroupID FROM
YourQuery")
rst.MoveLast
Me.Section(6).V isible = 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).V isible = DCount("*","You rGroupsQuery") > 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!txtGrandTota l)

On 27 Aug 2005 18:39:21 -0700, "Darin" <go****@darincl ine.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****@darincli ne.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****@darincli ne.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.groupfoote r.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****@darincli ne.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
15954
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 hooked up to interfaces. The Gtk is more than enough gui.
1
12425
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 chosen (i.e. the title changes to say "Sorted by Name" or "Sorted by Field"). For one of the options, "Sort by Field" I would not only like to have them sorted by Field alphabetically, but I would like to Group them and have a Group Header and...
11
4823
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 to hit - they don't work at all. Its true. I created 'em with the built-in wizard furnished with Access 97 but they do not work. I put 12 of 'em in the group, labeled the months of the year and giving
7
3433
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, tblEvents.eventcity, tblEvents.eventstate, tblEvents.eventstartdt, tblEvents.eventenddt, tblTrials.trialnbr, tblTrials.trialdt, tblTrialClass.trialclassID, tblClasses.class, tblScores.score, tblScores.level, . & (" "+.+".") & " " & . & (" "+.+".") & " (" & . & ",...
3
1770
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: This is an attendance report for Summer School ( Students may be enrolled in both a AM session or a PM session and could be absent in one or both.) I have a report that is Grouped first by Student ID, then by date, in the detail section, I have...
28
6707
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 id="content" style="position: absolute; top: 0; left: 255px; width: 700px; z-index:-1; background-color: transparency;"> Blah blah blah </DIV> </BODY>
1
1802
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: =(Section(8). Like >o I have also tried making the footer invisible then using the onformat expression: =(>)=Section(8).) needless to say neither one of these ideas. Does anyone have any thoughts? I feel like I am going about this the...
0
2725
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 row. I would like to display the footer row, only when a LinkButton "Add New" is clicked. And after the new record is saved to the database, let the footer row disappear. In the LinkButton's click event handler, I simply say:
3
4573
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 staff members: 2 ATTENDEES:
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9673
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10602
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10260
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9388
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.