Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Write calculated field to table

Write calculated field to table

Write calculated field to table

I will start by saying, I am a pilot not a programmer.
I have a form opened that is called mission Details and it is using a table called MissionDetails. When the aircraft start time and stop are enter, that is stored in MissionDetails table. These times are entered as 10:31, 14:20 etc. I have a calculated (text Box ) on the form that makes a decimal from that " =(([StopTime]-[StartTime])*24) ". It is displayed in a (text Box) called "timeToFraction". The table " MissionDetails " has a field called "timeToFraction" I need to write that number(timeToFraction) to the table when it is updated in the "TimeToFraction" text Box. I have no idea where to start.

Aubrey Price
Chief Pilot
Airborne Imaging Inc.

RE: Write calculated field to table

Just my opinion, but I would NOT keep any calculated field in a table.
Let's say you do, and you have data like this:

StartTime  StopTime  timeToFraction
  10:30      14:30       4:00
  12:00      13:30       1:30
  15:00      16:30       7:15
First 2 records make sense, what about the last record? Which data is correct? And which data is garbage? You will never know.

Create a query and calculate timeToFraction in the query. It will always be correct.

---- Andy

There is a great need for a sarcasm font.

RE: Write calculated field to table

I'm a programmer not a pilot winky smile so I would not store the calculated value. It just creates undue maintenance since you can always calculate the value in a control source like you have already done or in a query.

One of the needs for storing a calculated value is in an order detail table where discounts or prices vary over time.

If you really think you need to store the value, you could add some code to the After Update event of the start and stop fields like the following which uses a single sub that is called from each controls after update:

CODE --> vba

Private Sub StartTime_AfterUpdate()
End Sub
Private Sub StopTime_AfterUpdate()
End Sub
Sub CalcTime()
    Me.TimeToFraction = ([StopTime] - [StartTime]) * 24
End Sub 

Hook'D on Access
MS Access MVP 2001-2016

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close