Dynamic crosstab report - need help on Grouping Total

I created my Dynamic Crosstab report and get a total at the bottom of the report but need a grouping total, I pasted the Report Footer code to the Group Footer but it's doing a running total.

Using example of dynamic form attached .  All is working but I need to SUBTOTAL and I cannot get it ito work
Sheila MurphyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Dev-Soln LLCCommented:
I'm on my iPad, so cannot see what you have done, but for a group footer, you need to configure the report to group by one or more fields.  Then makes sure you have the Group Footer turned on, and then insert control(s) in the footer and set their control sources to something like:

ControlSource: =Sum([Field1])

Sheila MurphyAuthor Commented:
This is very different using code to make the dynamic fields.
The Report Footer fields are created by:
Private Sub ReportFooter4_Print(Cancel As Integer, PrintCount As Integer)
    Dim intX As Integer

    '  Place column totals in text boxes in report footer.
    '  Start at column 2 (first text box with crosstab value). 8/25/16 change intX = 2 to 4 sem
    For intX = 4 To intColumnCount
        Me("Tot" + Format(intX)) = lngRgColumnTotal(intX)
    Next intX

    '  Place grand total in text box in report footer.
    Me("Tot" + Format(intColumnCount + 1)) = lngReportTotal

    '  Hide unused text boxes in report footer.
    For intX = intColumnCount + 4 To conTotalColumns
        Me("Tot" + Format(intX)).Visible = False
    Next intX
End Sub

So I copied the same code to my new grouping and the problem is it is giving me a running total, not "subtotal" for each grouping
Sheila MurphyAuthor Commented:
Report Attached - note the subtotal for "QS" is actually a running total
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Dale FyeOwner, Dev-Soln LLCCommented:
again from my iPad, so cannot see your actual data, but if you click on those textboxes in the group and page footer, there is a property {Running Sum) in the Data tab which has options of No, Over Group, and Over All.  Set that property to "Over Group" for the group footer controls and "Over Report" for the Report tooter controls.

Then instead of using the Group and Report footer Print events, use code similar to what you use for the controls on the main form to set the control source of each of the controls to the proper field name, something similar to:

me.controls("txt_grp_Col" & x).ControlSource = "[" & me.fields(x).FieldName & "]"'
Sheila MurphyAuthor Commented:
Thanks, I have already played with the Running Sum, no difference with all the different settings (No, over group, over all).

I am not messing with the code, all the fields are created "on print": headers, detail and totals. The Access database I attached is the example I used to make my crosstab report dynamic because I have varying start dates for each employee and do not want to hard code any fields.
Sheila MurphyAuthor Commented:
Dale FyeOwner, Dev-Soln LLCCommented:
I'll have to look at it when I get access to my computer, maybe tomorrow AM.

I generally set the control source for all of the controls in my dynamic XTab reports in the report load event.  At that point, you know all of the columns used and can set those properties once and only once.  Then you don't need to mess with them in the Print events, which will slow down the report, especially if you are doing that in the Detail section as well as in the group and page or report footer events.
Sheila MurphyAuthor Commented:
The code I am using does not have anything in the "On Load" of the report.  The "On Open" calls out the record set and the variable to hold number of columns in crosstab .  The first database is the example I used.  I am also attaching "SeaTime.mdb" which has my report.  Need to open form "mnuOtherReports" and select an employee to run the report.
Dale FyeOwner, Dev-Soln LLCCommented:

I've been out of town for most of the last week and am trying to catch up.  I'll try to get back to this in the next 24 hours.
Sheila MurphyAuthor Commented:
I really appreciate you help
Dale FyeOwner, Dev-Soln LLCCommented:

The sample database you provided does not have the same fields as you are depicting in the attached jpg files.  I'll try to work with what you gave me.
Dale FyeOwner, Dev-Soln LLCCommented:
Take a look at what I've done with your report now.  I moved all of the formatting of the controls into the form_Open event, changed the column headers to caption controls as well as the Products, Category Total and Totals controls on the left side of the page.
Sheila MurphyAuthor Commented:
The second database (last attached) attached has the same fields.  I will take a look at what you attached right now, thank you for your help
Dale FyeOwner, Dev-Soln LLCCommented:
sorry, I missed the 2nd database, I saw the two jpg files, does that count for something?
Sheila MurphyAuthor Commented:
JPG was just showing report.   I am attaching "SeaTime.mdb".  Need to open form "mnuOtherReports" and select an employee to run the report.  I just removed all Event s from each report section and changed the On Open.

I am trying to implement your change into my SeaTime.mdb I attached but I continue to get errors or Access stops responding.  The 2 know differences is the recordsource and parameter which i changed under OPEN event of report

'''Set qdf = dbsReport.QueryDefs("A_qrySeaTime")
     Set qdf = dbsReport.QueryDefs(Me.RecordSource)  
    ' Set parameters for query based on values entered
'''I added for emp name 8/25/16
qdf.Parameters("Forms!mnuOtherReports!txtEmployee") = frm!txtEmployee
' I also added frm as DIM with On Open

Option Compare Database   'Use database order for string comparisons.
Option Explicit

'  Constant for maximum number of columns EmployeeSales query would
'  create plus 1 for a Totals column.
'sem change to 15 8/26/16
Const conTotalColumns = 15
Dale FyeOwner, Dev-Soln LLCCommented:
headed out for the evening, but if we have power in the AM, I'll take at look at it then.

Sheila MurphyAuthor Commented:
Sounds like you are where i am when it comes to weather.  I am in Hawaii waiting for Lester to hit.  You must be on the east coast waiting for Hermes . .  .
Dale FyeOwner, Dev-Soln LLCCommented:
Attached should work fine now.

I got rid of all of the additional code in the reports code module besides the Open and NoData events.

I also modified the column headers to be labels, and set the Captions property to the column headers.

I also renumbered basically all of the controls so that the control number corresponds with the recordset column number, which is zero based, so the 1st column (Boat) actually appears with a column index of zero in the recordset.

Then I set the ControlSource for the controls in the detail section by wrapping the field name in brackets.

For the totals rows, I modified the RunningSum property of both the BoatXX and TotXX controls to No, and set the ControlSource of each of the controls so that they would sum over each column:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sheila MurphyAuthor Commented:
This is excellent - thank you for taking the time to help me.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.