View Full Version : Formulas in Fields


jaspers
07-04-2002, 07:56 PM
Help!
I have a table that is used to track employee turn-over rates in my office.

How do I get the results of FieldA - FieldB into FieldC?
:confused:

CJBIRKIN
07-04-2002, 11:53 PM
Hello
First you need to make sure that you have a blank field in your table called C (your example). You then need to do an update query, in query design select update query. select field [C]. In the -update to- row enter [A]-[B]. when you run the query field [C] will be updated with the product of the calculation.

If your using dates I would use the datediff function (see help file)

Chris

Rich
07-05-2002, 01:09 AM
You shouldn't generally store the results of a calculation, use a calculated field in a query, or a calculated control on a form/report

CJBIRKIN
07-05-2002, 02:18 AM
Rich
In most cases I would agree with you, however i've found when looking at large data sets its faster to run an update query for the empty records and then run any subsequent queries off the table, rather than calculating the whole data set every time.
May be i've just got a slow computer!!.

jaspers
07-06-2002, 06:17 PM
Everyone,
Thanks for getting me on the right track.

What I ended up doing was to create the fields where the formulas would appear, created data input forms and reports and inserted the formulas inside the fields via the form or the report.

For example:

The TOTALS field will contain the results of FIELD_A + FIELD_B, the syntax entered into the TOTALS field was (RIGHT-CLICK on the TOTALS field and open PROPERTIES), TYPE:
= [FIELD_A] + [FIELD_B].

and viola, the results very nicely is displayed.

I would not have been able to accomplish this without your noble replies. Mucho gracias, Danke, Merci, THANKS!

:D

Pat Hartman
07-07-2002, 05:57 PM
If there is any possibility that either of the fields can be null, you'll need to use the Nz() function to avoid the dreaded #Error.

= Nz([FIELD_A],0) + Nz([FIELD_B],0)

jaspers
07-09-2002, 11:21 AM
Pat Hartman,
Thank you, reply was timely, that very message appeard and puzzled me.

jaspers

Pat Hartman
07-09-2002, 01:19 PM
Having made just about every mistake possible (I've had 30 years of practice), I've gotten pretty good at anticipating :D