If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Time calculation
Hi gang,
I've already been he http://www.mvps.org/access/datetime/date0004.htm I have 2 time fields, "Time In" and "Time Out". I have a third field, a number field, that is to receive a difference of the 2. Like I said, I tried the expression from the link above and got this error: "The database engine does not recognize either the field "Time In" in a validation expression, or the default value in the table "Task" " I'm assuming the expression from the link is to go into the Default Value section of the intemded field. Can anyone please explain to me,like a 4-year old, what I did incorrectly?? Thanks very much, Paul |
#2
|
|||
|
|||
"Paul" wrote in message
... Hi gang, I've already been he http://www.mvps.org/access/datetime/date0004.htm I have 2 time fields, "Time In" and "Time Out". I have a third field, a number field, that is to receive a difference of the 2. Like I said, I tried the expression from the link above and got this error: "The database engine does not recognize either the field "Time In" in a validation expression, or the default value in the table "Task" " I'm assuming the expression from the link is to go into the Default Value section of the intemded field. No, it goes in the ControlSource (assuming you're talking about a Form which actually "controls", not "fields"). -- I don't check the Email account attached to this message. Send instead to... RBrandt at Hunter dot com |
#3
|
|||
|
|||
Actually, Rick, I was talking not about forms, as I
hadn't even progressed taht far I did kind of a rush job on this, and am entering data right at the datasheet level of the table itself. That's why I was hoping I could utiize the Format fucntion of the expression builder attached to the Default Value of the field itself in the table. Does all this mean that function won't work on that level? Thanks again for your time. Paul -----Original Message----- "Paul" wrote in message ... Hi gang, I've already been he http://www.mvps.org/access/datetime/date0004.htm I have 2 time fields, "Time In" and "Time Out". I have a third field, a number field, that is to receive a difference of the 2. Like I said, I tried the expression from the link above and got this error: "The database engine does not recognize either the field "Time In" in a validation expression, or the default value in the table "Task" " I'm assuming the expression from the link is to go into the Default Value section of the intemded field. No, it goes in the ControlSource (assuming you're talking about a Form which actually "controls", not "fields"). -- I don't check the Email account attached to this message. Send instead to... RBrandt at Hunter dot com . |
#4
|
|||
|
|||
On Sat, 18 Sep 2004 08:32:34 -0700, "Paul"
wrote: Hi gang, I've already been he http://www.mvps.org/access/datetime/date0004.htm I have 2 time fields, "Time In" and "Time Out". I have a third field, a number field, that is to receive a difference of the 2. Like I said, I tried the expression from the link above and got this error: "The database engine does not recognize either the field "Time In" in a validation expression, or the default value in the table "Task" " Reread the explanation on the website. You cannot and should not store this time difference in a Table - *at all*. 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] Join the online Access Chats Tuesday 11am EDT - Thursday 3:30pm EDT http://community.compuserve.com/msdevapps |
#5
|
|||
|
|||
Paul
To add to Rick's and John's suggestions, I would ask a clarifying question. What data type are you using to hold the "time" values. I'm unaware of an Access datatype for "time" only. -- More info, please ... Jeff Boyce Access MVP |
#6
|
|||
|
|||
These answers seem very complicated.
Assuming you have TimeIn and TimeOut in TableName, the following functions will readily generate the difference: NetWorkDays([TableName]![timeIn],[TableName]![timeOut]), if you like, or DateDiff("s",[TableName]![time1],[TableName]![time2]) for seconds, "d" for days, etc. You definitely should NOT store this, as the number can readily be calculated from information in the table. Scott "Paul" wrote in message ... Hi gang, I've already been he http://www.mvps.org/access/datetime/date0004.htm I have 2 time fields, "Time In" and "Time Out". I have a third field, a number field, that is to receive a difference of the 2. Like I said, I tried the expression from the link above and got this error: "The database engine does not recognize either the field "Time In" in a validation expression, or the default value in the table "Task" " I'm assuming the expression from the link is to go into the Default Value section of the intemded field. Can anyone please explain to me,like a 4-year old, what I did incorrectly?? Thanks very much, Paul |
#7
|
|||
|
|||
Um, there's no NetWorkDays function in Access, Scott.
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "goofy" wrote in message ink.net... These answers seem very complicated. Assuming you have TimeIn and TimeOut in TableName, the following functions will readily generate the difference: NetWorkDays([TableName]![timeIn],[TableName]![timeOut]), if you like, or DateDiff("s",[TableName]![time1],[TableName]![time2]) for seconds, "d" for days, etc. You definitely should NOT store this, as the number can readily be calculated from information in the table. Scott "Paul" wrote in message ... Hi gang, I've already been he http://www.mvps.org/access/datetime/date0004.htm I have 2 time fields, "Time In" and "Time Out". I have a third field, a number field, that is to receive a difference of the 2. Like I said, I tried the expression from the link above and got this error: "The database engine does not recognize either the field "Time In" in a validation expression, or the default value in the table "Task" " I'm assuming the expression from the link is to go into the Default Value section of the intemded field. Can anyone please explain to me,like a 4-year old, what I did incorrectly?? Thanks very much, Paul |
#8
|
|||
|
|||
Hey John,
Just wanted to let you know you convinced me. I removed the "Hours" field in the database and now emply calculatons where I need them. I think I balked initially at that solution, because I have separate date and time fields, and it seemed like a pain in the ass, but simple concatenation worked fine. Thanks again, John. You're always a big help. Paul "John Vinson" wrote: On Sat, 18 Sep 2004 08:32:34 -0700, "Paul" wrote: Hi gang, I've already been he http://www.mvps.org/access/datetime/date0004.htm I have 2 time fields, "Time In" and "Time Out". I have a third field, a number field, that is to receive a difference of the 2. Like I said, I tried the expression from the link above and got this error: "The database engine does not recognize either the field "Time In" in a validation expression, or the default value in the table "Task" " Reread the explanation on the website. You cannot and should not store this time difference in a Table - *at all*. 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] Join the online Access Chats Tuesday 11am EDT - Thursday 3:30pm EDT http://community.compuserve.com/msdevapps |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Elapsed Time Calculation? | Ken | General Discussion | 1 | September 15th, 2004 08:51 PM |
time zone & apt times auto changing | Mary | Calendar | 6 | May 25th, 2004 05:44 AM |
time calculation | David McRitchie | Setting up and Configuration | 2 | March 28th, 2004 09:14 PM |