You create a query that does the calculation, and use the query as the
recordsource for the form, not the table.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
If I don't store the calculated field in the table, how do I represent
in the datasheet view o the subform?
If as you suggested, in the subform, I need to display 3 columns,
EmployeeDailyRate <-- field from table, user to enter
EmployeeDaysWorked <-- field from table, user to enter
EmployeePay <-- auto-calculate
How do I link this subform to record set? And how to trigger the
auto-calculation?
On Fri, 18 May 2007 16:26:08 +1000, "Alan T"
<
[email protected]>
wrote:
I have a subform.
The link table of this subform is tblCharges, fields are:
ID
EmployeeDailyRate
EmployeeDaysWorked
EmployeePay
I need to calculate the EmployeePay and fill in the value after I
entered
the EmployeeDailyRate and EmployeeDaysWorked.
EmployeePay = EmployeeDailyRate * EmployeeDaysWorked
Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.
Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.
John W. Vinson [MVP]