Calculate Equation

H

HMHD Manager

I am using the expression =[BodyMassIndex1]=[Weight1]/[Height1]/[Height1]*703
to calculate students' Body Mass Index in a form. I'm obviously typing it in
wrong. I want the field called BodyMassIndex1 to automatically compute when
the height is entered into the field called Height1 and the weight is entered
into the field called Weight1. Is this even possible? Thanks for your help!
 
J

John W. Vinson

I am using the expression =[BodyMassIndex1]=[Weight1]/[Height1]/[Height1]*703
to calculate students' Body Mass Index in a form. I'm obviously typing it in
wrong. I want the field called BodyMassIndex1 to automatically compute when
the height is entered into the field called Height1 and the weight is entered
into the field called Weight1. Is this even possible? Thanks for your help!

The field BodyMassIndex1 should *NOT EXIST* in your table.
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.

You can display it on a form or report in one of two ways: create a textbox
with a control source like

=703 * [Weight1]/([Height1]*[Height1])

or in a Query (upon which you can base a form or report) by putting

BodyMassIndex1: 703 * [Weight1]/([Height1]*[Height1])

in a vacant Field cell in the query design window.


John W. Vinson [MVP]
 
L

Linq Adams via AccessMonster.com

Besides showing you where to place your code, John also corrected your
formula, although he didn't point this out.

In part, you were using

[Height1]/[Height1]

when, as John's code shows, you should be using

([Height1]*[Height1])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top