Solved

Dynamic crosstab report - need help on Grouping Total

Posted on 2016-08-25
19
38 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:smurphy04
  • 10
  • 9
19 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
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:smurphy04
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:smurphy04
ID: 41772135
Report Attached - note the subtotal for "QS" is actually a running total
Employee-Sea-Time-Access-Report.pdf
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
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:smurphy04
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
 

Author Comment

by:smurphy04
ID: 41772359
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
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:smurphy04
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 47

Expert Comment

by:Dale Fye (Access MVP)
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:smurphy04
ID: 41780838
I really appreciate you help
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
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 47

Expert Comment

by:Dale Fye (Access MVP)
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:smurphy04
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 47

Expert Comment

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

Author Comment

by:smurphy04
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 47

Expert Comment

by:Dale Fye (Access MVP)
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:smurphy04
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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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:smurphy04
ID: 41783366
This is excellent - thank you for taking the time to help me.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

759 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

20 Experts available now in Live!

Get 1:1 Help Now