I don't understand why you feel you need to store a calculation. An AR
database would simply have a transaction table. Each invoice or credit
would be ONE record in your transaction table with a positive number. Each
payment would be a single record in your transaction table with a negative
number. To produce statements, you'd simply pull records for the date
specified.
Is this a balance forward schedule? Or open item?
If it is balance forward, then you would need to pull all entries prior to
the first of this month and total those in a query. That total would be the
first line on your statement and it would say....
Balance forward...........$ xx.xx
Then, all details from the current month would be shown as separate details.
Your footer would include the total for all details plus the balance
forward.
If it is an open item schedule, then you'd simply pull all invoice/reference
numbers that do not clear out to zero.
--
Rick B
Alex,
With this complete thread I understand the focus on a normalized db. If I
can't save a total amount to a record, can you give me some direction as
to
how do this?
michael
:
Hi Brook,
Allen is totally correct you should try to never store a value in a
table
that can be calculated at any point in time from other data, the trouble
with storing it is, if the underlying data that makes up the calculation
changes you need to recalculate the total. In your specific example what
if
one item on the invoice was credited, you would have to recalculate the
total when you entered the credit, where as by calculating when you need
the
total you just need to calculate at the point of running the report or
form,
meaning your total has a much greater chance of being correct. Less
things
to go wrong.
And I go with the idea that if it can go wrong it will, your business
logic
is far simpler by adopting this method rather than trying to store the
total
in the database.
Hope it helps.
--
Regards
Alex White MCDBA MCSE
http://www.intralan.co.uk
Allen,
Thanks for all the information, I guess I should explain why I am
trying
to perform the task at hand.
I am trying to set up and A/R table so that I can have my
invoicedate,
invoicenumber, invoicetotal, and add fields for payments. My client
pay
their
invoice on a monthly basis due in 90 days after the invoice date, and
that
is
why I have been trying to create this.
Thanks again, and if you have any suggestion on how I can accomplish
what
I am trying to do, please pass it on.
Brook
:
Brook, to find out why, locate and read anything on the topic,
"normalization".
If you want a whole book on the topic, try:
Rebecca M. Riordan "Designing Effective Database Systems" (Lebanon
IN:
Addison Wesley Professional, 2005) ISBN: 0321290933
The basic idea is that you ask Access to give you the total when you
need
it. DSum() is a simple approach. In a Form Footer or Report Footer,
you
can
use:
=Sum([Amount])
Then the field is never wrong.
For a working example, open the Northwind sample database, and see
the
Orders form, and the Invoice report.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Allen,
Thanks for the suggestion, but how would you recommend that I
"maintain"/
save my totals?
Do you have any suggestions?
Why do you feel so strongly about not saving the values from the
form?
Brook
:
Don't do it!
Seriously, you are only causing yourself more grief by saving the
total
and
trying to keep it up to date under every circumstance.
I have my invoice form, that has the following calculated fields:
totalshipping
invoicesubtotal
I would like to be able to save these calculated fields to my
tlbinvoicedetails.
Any ideas? suggestions.
Brook