Yet another Runing Totals query

lucy6868

Registered User.
Local time
Today, 10:35
Joined
Mar 16, 2010
Messages
15
I have read through the threads on creating a Running Total and am still stuck so here goes...

[FONT=&quot]I am trying to write a query that will return the running total of demand by part number by date.[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Table:[/FONT]
[FONT=&quot]tblLateOrders[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Fields:[/FONT]
[FONT=&quot]PartNumber[/FONT]
[FONT=&quot]OrderDate[/FONT]
[FONT=&quot]DemandQty[/FONT]
[FONT=&quot]DemandRunningTotal (which I'm trying to populate)[/FONT]
[FONT=&quot]AvailableQty (which I'm trying to populate)[/FONT]
[FONT=&quot]QtyOnHand[/FONT]

[FONT=&quot][/FONT]
[FONT=&quot]I've come up with:[/FONT]

[FONT=&quot][/FONT]
[FONT=&quot]SELECT tblLateOrders.PartNumber, tblLateOrders.OrderDate, Sum(tblLateOrders.DemandQty) AS SumOfDemandQty, Val(DSum("DemandQty","tblLateOrders","PartNumber = '" & [PartNumber] & "' AND OrderDate <= #" & [OrderDate] & "#")) AS RunningTotal
FROM tblLateOrders
GROUP BY tblLateOrders.PartNumber, tblLateOrders.OrderDate, Val(DSum("DemandQty","tblLateOrders","PartNumber = '" & [PartNumber] & "' AND OrderDate <= #" & [OrderDate] & "#"))
ORDER BY tblLateOrders.PartNumber, tblLateOrders.OrderDate;
[/FONT]
[FONT=&quot] [/FONT]
Which gives me a "Data type mismatch in criteria expression" error.

I can post/email my database if you tell me how to do it.

Any help would be appreciated!

Lucy
 
I figured it out:

UPDATE tblLateOrders SET tblLateOrders.DemandRunningTotal = DSum("DemandQty","tblLateOrders","PartNumber = '" & [PartNumber] & "' AND [OrderDate] <= #" & [tblLateOrders]![OrderDate] & "#");
 

Users who are viewing this thread

Back
Top Bottom