Jane-
You could try an expression like:
Daily: IIf(IsNull(DLookup("VehicleCostID", "tblVehicleCosts", "CostDate = #" & [CostDate] & "# AND VehicleCostID > " & [VehicleCostID], DSum("Price * Qty", "tblVehicleCosts", "CostDate = #" & [CostDate] & "#"), Null)
What this is doing: If there is no other record with the same CostDate and an ID greater than the current record (in other words, this is the last record for the date), then return the Sum of Price times Qty for all records with the same CostDate. If not the last record, then return a "blank". This should still execute a DLookup for each row, but it will do the Sum only when on the last row for a given date.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Jul 5, 2016, at 3:44 PM, jcross@crossproducts.plus.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Hi John
Yes each record has a unique VehicleCostID -autonum PK.
tblVehicleCosts
VehicleCostID - autonum PK
VehicleIDFK long
CostDate date
PartDesc Text
Price Currency
Qty Double
Units Text
NettTotal Currency
Thanks John
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Jane-
What is the layout of the table? Is there possibly an AutoNumber primary key? If so, I might be able to come up with something.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Jul 5, 2016, at 12:47 PM, jcross@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
__._,_.___
Posted by: John Viescas <johnv@msn.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (4) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
.
__,_._,___
Tidak ada komentar:
Posting Komentar