Form Calculations are lost to table feilds

P

postman

This is a problem I've been wrestling with for a while now, & it comes up again:
Its where I can make calculations in unbound text boxes on a form work, but if they are

bound to a table then I loose the calculations in the record source to the table field,

eg:

I'm building a cash register form with these text boxes:

SUB-TOTAL
GST
DISCNT (is a combo box with 'value list row source: .1;.15;.20;.25;.50)
TOTAL
TENDERED
CHANGE.

If I have these form text boxes 'unbound' then its simple to make it work with the

following calculations in the corresponding control Source of the text boxes:

SUB-TOTAL (1st data input)
GST=[Total]*0.1
DISCNT=**NOT SURE ABOUT THIS ONE YET-NEED TO CALCULATE, & RECORD PERCENTAGE & CALCULATED

AMOUNT from Total box**
TOTAL=[SubTotal]-[Discnt]
TENDERED (2nd data input)
CHANGE=[Tendered]-[Total]

Tabbing through the boxes after data inputs makes the calcs work.

But If the control sources are bound to a table (tbl_CReg), I then loose the calculations!
Where do the calculations go if controls are bound?

Thanks in advance.
 
A

Allen Browne

See:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

The article explains how to use create calculated fields in a query, and
when and how to store them in a table.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

This is a problem I've been wrestling with for a while now, & it comes up
again:
Its where I can make calculations in unbound text boxes on a form work, but
if they are

bound to a table then I loose the calculations in the record source to the
table field,

eg:

I'm building a cash register form with these text boxes:

SUB-TOTAL
GST
DISCNT (is a combo box with 'value list row source: .1;.15;.20;.25;.50)
TOTAL
TENDERED
CHANGE.

If I have these form text boxes 'unbound' then its simple to make it work
with the

following calculations in the corresponding control Source of the text
boxes:

SUB-TOTAL (1st data input)
GST=[Total]*0.1
DISCNT=**NOT SURE ABOUT THIS ONE YET-NEED TO CALCULATE, & RECORD PERCENTAGE
& CALCULATED

AMOUNT from Total box**
TOTAL=[SubTotal]-[Discnt]
TENDERED (2nd data input)
CHANGE=[Tendered]-[Total]

Tabbing through the boxes after data inputs makes the calcs work.

But If the control sources are bound to a table (tbl_CReg), I then loose the
calculations!
Where do the calculations go if controls are bound?

Thanks in advance.
 
J

John Vinson

This is a problem I've been wrestling with for a while now, & it comes up again:
Its where I can make calculations in unbound text boxes on a form work, but if they are

bound to a table then I loose the calculations in the record source to the table field,

Read Allen's website for possible exceptions, but in general...

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]
 

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