how to save a calculated field in a form to a table

J

joe

Hai

Iam trying to develop a database in access for logging flight details for a
flying club and iam using Access 2007

I created a form called LogFlight which has few field like

Date of flight : current date
Wheels OFF Time: take off time of flight in 24 hr format
Wheels ON Time: landing time of flight in 24 hr format
DURATION: A calculated field using expression in control sourse
=DateDiff("n",[WheelsOffTime],[WheelsOnTime])

And a Save Button

I would like to save all these 3 field into a table called Account Table
having all of these 3 fields i tried but the field of Duration is showing
blank.

Is there any way to do this ??????

Thanks in Advance...........
 
J

John W. Vinson

Date of flight : current date
Wheels OFF Time: take off time of flight in 24 hr format
Wheels ON Time: landing time of flight in 24 hr format
DURATION: A calculated field using expression in control sourse
=DateDiff("n",[WheelsOffTime],[WheelsOnTime])

And a Save Button

I would like to save all these 3 field into a table called Account Table
having all of these 3 fields i tried but the field of Duration is showing
blank.

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.
 
A

ABRAHAM VENEZUELA

I need to solve a large formula (with logical conditions) which works ok in
the data FORM i created but the querys and reports are not taking it, every
time i enter the formula in a QUERY or REPORT field it produces an error.

In the other hand the calculated value depends on a large number of changing
paramenters i´m not really interested on save. I just want to save the result.

Can you help?









John W. Vinson said:
Date of flight : current date
Wheels OFF Time: take off time of flight in 24 hr format
Wheels ON Time: landing time of flight in 24 hr format
DURATION: A calculated field using expression in control sourse
=DateDiff("n",[WheelsOffTime],[WheelsOnTime])

And a Save Button

I would like to save all these 3 field into a table called Account Table
having all of these 3 fields i tried but the field of Duration is showing
blank.

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.
 
J

John W. Vinson

On Mon, 18 Aug 2008 14:55:01 -0700, ABRAHAM VENEZUELA <ABRAHAM
I need to solve a large formula (with logical conditions) which works ok in
the data FORM i created but the querys and reports are not taking it, every
time i enter the formula in a QUERY or REPORT field it produces an error.

In the other hand the calculated value depends on a large number of changing
paramenters i´m not really interested on save. I just want to save the result.

Can you help?

You can use some appropriate form event - the Form's BeforeUpdate, or a Click
event of a command button, or something else appropriate - to "push" the
calculated result into a bound control. Let's say you have a textbox
txtCalculated on the form which contains the result of the calculation; put
another textbox txtResult bound to the table field in which the result should
be stored.

In the event (whatever it is) just set txtResult to txtCalculated:

Me!txtResult = Me!txtCalculated
 

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