I have read through the threads on creating a Running Total and am still stuck so here goes...
[FONT="]I am trying to write a query that will return the running total of demand by part number by date.[/FONT]
[FONT="] [/FONT]
[FONT="]Table:[/FONT]
[FONT="]tblLateOrders[/FONT]
[FONT="] [/FONT]
[FONT="]Fields:[/FONT]
[FONT="]PartNumber[/FONT]
[FONT="]OrderDate[/FONT]
[FONT="]DemandQty[/FONT]
[FONT="]DemandRunningTotal (which I'm trying to populate)[/FONT]
[FONT="]AvailableQty (which I'm trying to populate)[/FONT]
[FONT="]QtyOnHand[/FONT]
[FONT="][/FONT]
[FONT="]I've come up with:[/FONT]
[FONT="][/FONT]
[FONT="]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="] [/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
[FONT="]I am trying to write a query that will return the running total of demand by part number by date.[/FONT]
[FONT="] [/FONT]
[FONT="]Table:[/FONT]
[FONT="]tblLateOrders[/FONT]
[FONT="] [/FONT]
[FONT="]Fields:[/FONT]
[FONT="]PartNumber[/FONT]
[FONT="]OrderDate[/FONT]
[FONT="]DemandQty[/FONT]
[FONT="]DemandRunningTotal (which I'm trying to populate)[/FONT]
[FONT="]AvailableQty (which I'm trying to populate)[/FONT]
[FONT="]QtyOnHand[/FONT]
[FONT="][/FONT]
[FONT="]I've come up with:[/FONT]
[FONT="][/FONT]
[FONT="]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="] [/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