Calculated Field

  • Thread starter Thread starter rogerscmg
  • Start date Start date
R

rogerscmg

Im fairly new to access, and have a quick question. I have 1 table
with a bunch of fields. of those fields, i have Open and Delivered (as
in a # of open emailed, and # of delivered emails). Id like to divide
the two fields to find a percentage, and then store that number in a
field called Open Rate, which also resides in the same table. how can
i SAVE this number to the table?
 
Im fairly new to access, and have a quick question. I have 1 table
with a bunch of fields. of those fields, i have Open and Delivered (as
in a # of open emailed, and # of delivered emails). Id like to divide
the two fields to find a percentage, and then store that number in a
field called Open Rate, which also resides in the same table. how can
i SAVE this number to the table?

1) Open is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html

2) It's easy enough to find the percentage (after you change the
field name from "Open" to, perhaps "MailOpen".

Using an UNBOUND text control on your form (or in a Report), set it's
control source to:

= [MailOpen]/[Delivered]

If you wish the value actually formatted as % ( i.e. 25% rather than
as a decimal .25) then set the format property of the control to
percent

3) There is no reason to save this calculated data in any table. Any
time you need the percentage, simply recalculate it, as above.
 
how can
i SAVE this number to the table?

Don't.

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]
 
Back
Top