Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamic crosstab report - need help on Grouping Total

Posted on 2016-08-25
19
Medium Priority
?
66 Views
Last Modified: 2016-09-03
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
Comment
Question by:Sheila Murphy
  • 10
  • 9
19 Comments
 
LVL 49

Expert Comment

by:Dale Fye
ID: 41771513
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
 

Author Comment

by:Sheila Murphy
ID: 41772125
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
 

Author Comment

by:Sheila Murphy
ID: 41772135
Report Attached - note the subtotal for "QS" is actually a running total
Employee-Sea-Time-Access-Report.pdf
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 49

Expert Comment

by:Dale Fye
ID: 41772311
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
 

Author Comment

by:Sheila Murphy
ID: 41772356
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
 
LVL 49

Expert Comment

by:Dale Fye
ID: 41772419
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
 

Author Comment

by:Sheila Murphy
ID: 41772532
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
 
LVL 49

Expert Comment

by:Dale Fye
ID: 41776586
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
 

Author Comment

by:Sheila Murphy
ID: 41780838
I really appreciate you help
0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 41781398
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
 
LVL 49

Expert Comment

by:Dale Fye
ID: 41781459
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
 

Author Comment

by:Sheila Murphy
ID: 41781824
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
 
LVL 49

Expert Comment

by:Dale Fye
ID: 41782328
sorry, I missed the 2nd database, I saw the two jpg files, does that count for something?
0
 

Author Comment

by:Sheila Murphy
ID: 41782352
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
 
LVL 49

Expert Comment

by:Dale Fye
ID: 41782359
headed out for the evening, but if we have power in the AM, I'll take at look at it then.

Dale
0
 

Author Comment

by:Sheila Murphy
ID: 41782362
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
 
LVL 49

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 41783142
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
 

Author Comment

by:Sheila Murphy
ID: 41783366
This is excellent - thank you for taking the time to help me.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

971 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