Alex, you will need to argue more strongly than that to convince use thisis
normalized.
You may be able to use the AfterUpdate event procedure of both the Quantity
and the [Unit Price] fields to execute an Update query statement to change
the Total in the 3rd table. But there's actually much more to it than that.
- The AfterUpdate event of the controls is not enough. If the record does
not get saved, the total would have been wrongly updated.
- The AfterUpdate event of the form could work. However, you don't have
access to the OldValue of the controls at this time, so you don't know if
the update is needed or not, unless you set flags in the BeforeUpdate event
of the form as well.
- You will also need to hook the AfterDelConfirm event of the form(s) where
entries are made that could affect the totals, so ensure the update happens
as well.
- If the unit price is in another table, you might want to worry about what
happens to existing records when you alter that price. Which existing
records should be altered, and which should not?
- Because the stored total could become wrong, you probably need to also
program some mechanism to correct it periodically so it does not become
gradually more wrong over time. Of couse, such a change affects existing
data and reports you have already run from the database, so that the datain
the database may no longer match the reported data at the previous times.
Are you *really* sure all the work you are taking on to maintain the
integrity of this non-normalized approach is worth the effort?
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
I have normalised some tables but it means I have a Total Cost field
in one table, a Quantity field in another and a n Item Price field in
a third table.
I want to be able to get the Total Price field to calculate
automatically but I am having trouble working out how to get that to
happen. Do I do this using a query or using the Default Value
property in table design view? Or should I just code it as an event
handler on the form?
Alex- Hide quoted text -
- Show quoted text -