MELee
08-26-2001, 12:32 PM
I want to look at a date in database field, and subtotal a different column from current record to 7 past (a week). If I can do this without VB and enter in form as a straight function, I would love some help. Otherwise, what is the VB equation?
Jack Cowley
08-26-2001, 01:33 PM
There are a couple of possiblities here and I am not sure exactly what you mean when you say 'from current record' to a 7 days past. You could have 20 records with the same date and be looking at just one of them so records previous to the one you are looking at would be the ones you want to sum, not records that follow. To do that you would need more than the code I am about to give you.
With the code below you can have a date field on a from called 'CurrentDate' and use this code to give you the sum of a field called 'MyNumbers'. Use this code as the Control Source for an unbound field on your form:
=DSum("[MyNumbers]", "MyTable", "[MyDate] Between #" & Me![CurrentDate] & "# And #" & Me![CurrentDate] - 7 & "#")