Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default value

Status
Not open for further replies.

authorsami

Instructor
Sep 11, 2003
155
US
Can the default value of a field be based on two other fields in the same table.

I want to track how long it takes to do a job so I have a [starttime1] and [endtime1]( I also have 2 and 3)

I want to have an [elaptime1], 2, and 3.

Can I use a default value for the ElapTime1?????

Thanks Sharon
 
Hi!

Since you are storing start time and end time you don't need to store elapsed time since it can be calculated any time you need it.

To answer your specific question, the default value for one field on a table cannot be based on another field in the table.


hth


Jeff Bridgham
bridgham@purdue.edu
 
Don't think so ... and storing computed values is a violation of third normal form. (i.e. a field should be dependent on the primary key, the whole primary key and nothing but the primary key.) "ElapTime1" would be dependent on "StartTime1" and "EndTime1" which I assume, are not the primary keys. You can however present your elapsed times in a query quite nicely ... for example
Code:
   Select DateDiff ( "n", [StartTime1], [EndTime1] ) As [ElapTime1], 
          [StartTime1], [EndTime1], ... etc.
 
Ok, so if I can calculate the total elapsed time at any time, how do I show it on a form and then later on a report??

SMD
 
Golom, cool I guess I need to do a query to fix this.

Thanks
SMD
 
Hi!

You can do the same thing in a form or report. Just create a text box and set the Control Source to:

=[EndTime1] - [StartTime1]

or by using the DateDiff function in Golom's post.

hth


Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top