Selasa, 05 Juli 2016

Re: [MS_AccessPros] Form Daily Running Sum

 

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:



Hi 

I have a continuous sub form where users enter vehicle costs (mileage, parts etc). They would like the form to display the daily running total next to the last entry for each day, but only for the last item of the day, eg

Date PartDesc Cost Daily Total

29-Jun  Labour £10

29-Jun  Mileage  £20

29-Jun Part 1  £5 £35

30-Jun  Labour £12

30-Jun Part 2 £4.99 £16.99

1-Jul Mileage £20 £20

2-Jul Part 1 £5

2-Jul Part 3 £55 £60


I've created a dsum function & a function with conditional formatting which works, but is too slow to use.

A query seems a better way to go, but the ones I've done have not been update-able so the user can't use it to enter costs.

Any suggestions?

Many thanks

Jane









__._,_.___

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