Grouping breakdown in report footer for grand total.

Posted on 2007-10-15
Last Modified: 2013-11-28
I have a report that is run by a query linked to two tables. Here is the sql of the query.

SELECT tblMailLog.[Delivered Date], tblMailLog.[Receive Date], tblSecurity.UserName AS Expr1, tblMailLog.UserID, tblMailLog.AccountNumOrName, tblMailLog.Abbreviation, tblMailLog.TypeOfMail, tblMailLog.Area, tblMailLog.[Completed Code], tblMailLog.Comments
FROM tblMailLog INNER JOIN tblSecurity ON tblMailLog.UserID = tblSecurity.UserID
WHERE (((tblMailLog.[Delivered Date]) Between [Forms]![frmNTEGReportssup]![txtsupsd] And [Forms]![frmNTEGReportssup]![txtsuped]));

This report is grouped by Delivered Date, By UserName, then by type of mail

There is a calculation in the header for the type of mail
=" (" & Count(*) & " " & IIf(Count(*)=1,"detail record","detail records") & ")"
and a calculation in the UserName footer
="Total " & " = " & " " & [User Name] & " (" & Count(*) & " " & IIf(Count(*)=1,"detail record","detail records") & ")"

I also have a grand total in report footer :
=" (" & Count(*) & " " & IIf(Count(*)=1,"detail record","detail records") & ")"

This will then breakdown the types of mail for each UserName. And a total of all records for the entire report. What I want is to also get a breakdown on the grand total for each mail type just above the grand total in the report footer. Any help will be great.
Question by:woodje
    LVL 92

    Accepted Solution

    I would do this by creating a new query that just grabs the counts by mail type, and using
    that query to populate the recordsource of a subquery embedded in the report footer.  That way,
    no maintenance is needed if new mail types get added later.

    The SQL would be something like:

    SELECT m.TypeOfMail, Count(*) AS Qty
    FROM tblMailLog m INNER JOIN
        tblSecurity s ON m.UserID = s.UserID
    WHERE m.[Delivered Date] Between [Forms]![frmNTEGReportssup]![txtsupsd] And [Forms]![frmNTEGReportssup]![txtsuped];
    GROUP BY m.TypeOfMail
    LVL 14

    Expert Comment

    I will include a subreport in the report footer to show all the total by mail type.

    the query of the subreport will be a group by:

    SELECT  tblMailLog.TypeOfMail, count(*) as MailTypeNbr
    FROM tblMailLog INNER JOIN tblSecurity ON tblMailLog.UserID = tblSecurity.UserID
    WHERE (((tblMailLog.[Delivered Date]) Between [Forms]![frmNTEGReportssup]![txtsupsd] And [Forms]![frmNTEGReportssup]![txtsuped]))
    group by tblMailLog.TypeOfMail;

    LVL 14

    Expert Comment

    Well, matthewspatrick was quicker than I...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now