I don't think it's likely there will be an amount 6, at the time being only
about 4 will be used so there are 2 spare just in case anyway.
In that case, your amount 6 will be needed in a month or so... or more likely
the next time that you're at the busiest and don't have time to restructure
your database to accommodate it.
Seriously - *THIS DESIGN IS WRONG*. Your problem with totals is due to the
flaw in your design. The many NULL Amounts are due to the flaw in your design.
The problem with searching is due to the flaw in your design.
You have a one to many relationship. Work *WITH* Access instead of struggling
against it, and pull the amounts out into a related table. Seriously... this
will make your job easier, not harder. If you would like help migrating your
data to the new structure post back, it's not at all hard.
The DATEFB field is Short Date.
An example of a record is as follows:
DATE FB AMOUNT1 AMOUNT2 AMOUNT3 AMOUNT4 AMOUNT5 TOTAL
10/01/2008 1200 1500 2000 1204
0 (4104)
() - ADDED FROM AMOUNT VALUES
If I then say had a record a week later with a total of 6234 I'd want my
report to say 2130 at the end of the row for that day because that is the
difference between the 17/01/08's total and the 10ths total.
SELECT A.DATEFB, B.DATEFB, (NZ(A.Amount1)+NZ(A.Amount2) + NZ(A.Amount3) +
NZ(A.Amount4) + NZ(A.Amount5)) AS ThisWeekAmount, (NZ(B.Amount1)+NZ(B.Amount2)
+ NZ(B.Amount3) + NZ(B.Amount4) + NZ(B.Amount5)) AS LastWeekAmount,
(NZ(A.Amount1)+NZ(A.Amount2) + NZ(A.Amount3) + NZ(A.Amount4) + NZ(A.Amount5))-
(NZ(B.Amount1)+NZ(B.Amount2) + NZ(B.Amount3) + NZ(B.Amount4) + NZ(B.Amount5))
AS Difference
FROM yourtable AS A INNER JOIN yourtable AS B
ON B.DateFB = A.DateFB-7
WHERE A.DateFB = [Enter date:];
THis will prompt for a date (you can use Date() instead of [Enter date:] to
always get today's date; total the amounts for that day - the A fields; total
the amounts for the date seven days prior - the B fields; and give you the
difference. This assumes that there will always be one DateFB value per week,
never missing a holiday or weather emergency or other missing data.
With the normalized design the query will be considerably simpler. Your
choice!
John W. Vinson [MVP]