Link to home
Start Free TrialLog in
Avatar of Sheila Murphy
Sheila MurphyFlag for United States of America

asked on

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
RptCrossTab2k.mdb
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

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])

HTH
Dale
Avatar of Sheila Murphy

ASKER

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
Report Attached - note the subtotal for "QS" is actually a running total
Employee-Sea-Time-Access-Report.pdf
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 & "]"'
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.
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.
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.
SeaTime.mdb
Sheila,

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.
I really appreciate you help
smurphy,

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.
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.
RptCrossTab2kModified.mdb
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
sorry, I missed the 2nd database, I saw the two jpg files, does that count for something?
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

and
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
SeaTime.mdb
headed out for the evening, but if we have power in the AM, I'll take at look at it then.

Dale
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 . .  .
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is excellent - thank you for taking the time to help me.