Code:
RunningSum: (select sum([DayCount]) from SampleTable ST where ST.dateField<=SampleTable.dateField)

Originally Posted by
June7
What was the expression you tried with DSum?
DSum("ValueField", "MyTable", "DateField<=#" & [datefield] & "#")
I completely agree with June.
DLookup is not suited to your need for a running total because it will only look up a single field result from a source, not from within the query dataset you are building--so you can't build a recursive consideration within the same query using DLookup. You can do so with DSum and an appropriate criteria (A.K.A. a where filter)
I would only add that you can do multiple criteria in all of the Domain functions, including DSum and DLookup.
The issue with Domain functions is that they are VBA-based rather than JET-based. Simply put, JET-based functions are faster because they don't have to go consult the VBA libraries. Instead they run entirely in the database engine.
If we take June's code that is a field definition:
Code:
DSum("ValueField", "MyTable", "DateField<=#" & [datefield] & "#")
If we want it to run in JET (fast), we need to make some adjustments. The field definition should instead be:
Code:
RunningSum: (select sum([ValueField]) from MyTable MT where MT.dateField<=MyTable.dateField)
You will also need to ensure you group by your MyTable.[dateField].
Allen Browne covers this a bit here: http://allenbrowne.com/QueryPerfIssue.html