Bind a calculated result in a form to a field in a table

G

Guest

Within a form, I have a text box that calculates a unit cost price by
dividing a total cost by a total unit. How do I get this to write to a field
name in a table for use in reports, etc...? I have tried adding the field
name to the form but as soon as I change the control source of the table
field name it becomes unbound and does not write the calculated value to the
table. Any thoughts?
 
R

Rob Oldfield

If you have three fields UnitCost, TotalCost and Units then you could just
use

me.unitcost=me.totalcost/me.units in the after update event of the total
cost and units controls.

Having said that, I think it's probably a bad idea. Unless you have some
situation where the unit cost is, for some reason, going to be different
from the calculation, then you're better off just storing total cost and
units. Then create a query that works out unit cost and base the report on
that.
 
G

Guest

Okay, I've got the calculated cost down by using a textbox on my main form.
The TotalCost and Units are totaled on subforms and displayed on the main
form. I then have an unbound textbox that calculates and displays the
UnitCost by taking the TotalCost/Units. However, how can I get this value to
show up on a report?
 
R

Rob Oldfield

Same thing again... create a query that does that calculation, and base your
report on that query.
 

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