You can use the DSum function to get just about any calculated totals for anything within your database tables. Here is an example:
In this example, a YTD sales amount is needed on the report, regardless of the period being printed.
If this is what you need, you can use the DSum function inside your report footer (or anyplace you choose to place it). To do this, simply add a textbox to the location you want, then add the DSum statement as follows for the recordsource of the textbox:
EXAMPLES: All records in table
=DSum("[Sales_amt]","tblSales")
Range of dates
=DSum("[Sales_amt]","tblSales","[Sales_date] between #01/01/2003# and #12/31/2003#")
All records for specific customer
=DSum("[Sales_amt]","tblSales", "[Customer_id] = '1234'")
All records for specific customer, with date range
=DSum("[Sales_amt]","tblSales", "[Customer_id] = '1234' and [Sales_date] between #01/01/2003# and #01/31/2003#")
Presumptions:
The field containing the sales amount is called Sales_amt.
The table containing the sales figures is called tblSales.
The field containing the sales date is called Sales_date.
Customer_id is a string datatype, therefore it needs single quote marks wrapped around it. If any field is a numeric datatype, single quotes must not be used, e.g., "[Customer_id] = 1234".
Feedback, comments?
Randy Smith, MCP
rsmith@cta.org
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.