PDA

Click to See Complete Forum and Search --> : Problem with summary report - summing fields


o9z1
Feb 28th, 2007, 11:45 AM
Ok, I have my report already completed with the design I want. I have tested the report as a Detail report only. My Select statement that populates the report was simply grabbing fields from the table and dropping them in the report.

I saved my dataset schema and imported it to the report. I then tested my report with just my detail report select statement. The report worked fine. I then changed my Select statement to Sum the fields. For example

Select Sum(Total), Sum(Price), Sum(Weight) From..............

When I use this Select statement, my report errors out that the field name is not known. Like I said, it works fine until I change the select statement in the vb code. Is there a change I need to make to get this to work?

brucevde
Feb 28th, 2007, 01:41 PM
The field name on the report must match a field name in the dataset. When you use an aggregate function in a sql statement you lose the original field name (names like Expr1, Expr2 are automatically assigned)

Simply assign an Alias name to the fields in the sql statement.

Select Sum(Total) As Total, Sum(Price) As Price, Sum(Weight) As Weight From..............