Solved

Cross tab report totals

Posted on 2013-06-02
9
482 Views
Last Modified: 2013-06-08
Hi, I have an access 2007 cross tab report that I am building at run time. I noticed that the total column does not add correctly. I have done the math several times and cannot see where it may be getting these amounts from. I have attached a sample below. I did not include the columns headings but the last column is supposed to add the columns.

Any help would be appreciated. The report is due tomorrow.
SampleReport.PNG
0
Comment
Question by:smolbeck367
  • 6
  • 3
9 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39214708
What code are you using to achieve this report?

I assume you are using the report Open or
Load event to assign columns to the control source of your controls.  What code are you using fot the control source of your totals column?  Are you using the NZ function!
0
 

Author Comment

by:smolbeck367
ID: 39214715
I am using the code below to generate the columns and total. I am not using NZ. I took this from Office help on creating dynamic cross tab reports.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
   
   Dim intX As Integer
   Dim lngRowTotal As Long

   '  If PrintCount is 1, initialize rowTotal variable.
   '  Add to column totals.
   If Me.PrintCount = 1 Then
      lngRowTotal = 0
       
      For intX = 2 To intColumnCount
         '  Starting at column 2 (first text box with crosstab value),
         '  compute total for current row in the "Detail" section.
         lngRowTotal = lngRowTotal + Me("Col" + Format(intX))

         '  Add crosstab value to total for current column.
         lngRgColumnTotal(intX) = lngRgColumnTotal(intX) + Me("Col" + Format(intX))
      Next intX
       
      '  Put row total in text box in the "Detail" section.
      Me("Col" + Format(intColumnCount + 1)) = lngRowTotal
      '  Add row total for current row to grand total.
      lngReportTotal = lngReportTotal + lngRowTotal
   End If
End Sub
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39214752
It looks like your columns are constant, since you are not doing anything with the other columns in this code.  If that is the case, I think I would use the form load event, and rather than compute the value of the totals column, would define a string that would become the control source of the totals column, something like (from my iPad so may contain typos).

Assuming your field names are like Col1, Col2, Col3, then try something like.

For intX =2 to intcolumncount.
    strCS = strCS & "+ NZ([col" & intX & "])"
Next
StrCS = mid(strCS, 2)
Me("col" + (intColUmnCount +1)).controlsource = strCS
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:smolbeck367
ID: 39214773
I built the report to accept the largest number of associates we have on a team. In our case that would be 11.  Those are my column names.  How would I adjust the code I have not to create the total column and replace it with your code. I am really new to cross tab reports and building them dynamically. I appreciate your patience and guidance.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39214902
Can you provide me a sample of the output of your Cross-tab query?  Output the query to Excel and change the row and column names as you see appropriate.  That way, I can simply import that into the example crosstab report database I have.  If you need to change the column headings that will be fine, you will get the idea.
0
 

Author Comment

by:smolbeck367
ID: 39214923
Here it is. This is one teams query results. I really appreciate your help.
Sample.xlsx
0
 

Accepted Solution

by:
smolbeck367 earned 0 total points
ID: 39216294
Is there anyone else that may be able to assist me with this question? The report is due this afternoon. I have take the steps to export to excel and update that way for today but I am really hoping that the managers will be able to run their team reports some time very soon. Thanks for the help.
0
 

Author Comment

by:smolbeck367
ID: 39216626
Closing Request - issue resolved.
0
 

Author Closing Comment

by:smolbeck367
ID: 39231330
I was able to find the answer to my question.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

825 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