• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 79
  • Last Modified:

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
0
Sheila Murphy
Asked:
Sheila Murphy
  • 10
  • 9
1 Solution
 
Dale FyeCommented:
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
0
 
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
0
 
Sheila MurphyAuthor Commented:
Report Attached - note the subtotal for "QS" is actually a running total
Employee-Sea-Time-Access-Report.pdf
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Dale FyeCommented:
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 & "]"'
0
 
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.
0
 
Sheila MurphyAuthor Commented:
0
 
Dale FyeCommented:
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.
0
 
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.
SeaTime.mdb
0
 
Dale FyeCommented:
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.
0
 
Sheila MurphyAuthor Commented:
I really appreciate you help
0
 
Dale FyeCommented:
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.
0
 
Dale FyeCommented:
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
0
 
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
0
 
Dale FyeCommented:
sorry, I missed the 2nd database, I saw the two jpg files, does that count for something?
0
 
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

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

Dale
0
 
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 . .  .
0
 
Dale FyeCommented:
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:

"=Sum([20XX])"
SeaTimeModified.mdb
0
 
Sheila MurphyAuthor Commented:
This is excellent - thank you for taking the time to help me.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now