HELP PLEASE!!!!!

T

TehSparrow

Ok, i have formatted a time date field to short time, but i only want access
to display the hours part, e.g. 2 or 3 hours. As i cant format access fields
into an hour format, i want to create an input mask, or some validation to
only allow the user to enter the 1, 2, or 3 hours

The 3 hours is then added to a start time to create an end time

Any help would be wonderful!!!!!!

Sparrow
 
R

Rick B

If you want the user to enter 1, 2, or 3 hours, then you do so in a numeric
field, not a time field. You can then use the DATEADD function to add that
number to a valid Date/Time field.

Of course, you don't need to store all three values. I'd just store the
start and end time and have the user make the entry in an unbound field.
 
K

Klatuu

TehSparrow said:
Ok, i have formatted a time date field to short time, but i only want access
to display the hours part, e.g. 2 or 3 hours. As i cant format access fields
into an hour format, i want to create an input mask, or some validation to
only allow the user to enter the 1, 2, or 3 hours

The 3 hours is then added to a start time to create an end time

Any help would be wonderful!!!!!!

Sparrow
 
T

TehSparrow

this doesnt work, the field must be a date/time for this expression to work!

End Time: [Length of lesson]+[Start time]

if i do date add:

End Time: DateAdd("h",[Start time],[Length of lesson])

with teh length of time as a numeric, the end time is displayed as a long
date, and wont display as a time
 
R

Rick B

End Time: Format(DateAdd("h",[Start time],[Length of lesson]),"????")

Not sure of the expression, but you could use format.
 
J

John Spencer

Syntax for DateAdd function is

DateAdd("h",[Length of Lesson],[StartTime])

So you can store Length of Lesson in number of hours and calculate the End
time when you need it by using the formula above.

Or you can assign the calculation results to a field and not store the
Length of Lesson.


Rick B said:
End Time: Format(DateAdd("h",[Start time],[Length of lesson]),"????")

Not sure of the expression, but you could use format.

--
Rick B



TehSparrow said:
this doesnt work, the field must be a date/time for this expression to
work!

End Time: [Length of lesson]+[Start time]

if i do date add:

End Time: DateAdd("h",[Start time],[Length of lesson])

with teh length of time as a numeric, the end time is displayed as a long
date, and wont display as a time
 
D

Douglas J Steele

You've got it backwards: the DateAdd function takes number first, then the
date:

End Time: DateAdd("h",[Length of lesson],[Start time])

If that still doesn't work, then try Rick's Format suggestion, but be aware
that that will change your time to a string.
 
T

TehSparrow

Rick said:
End Time: Format(DateAdd("h",[Start time],[Length of lesson]),"????")

Ok, but what do teh ? marks stand for? ive tried some different things with
the ^^^ but i cant seem to get it to work! any other ideas? PLEASE!!
 
T

TehSparrow

Douglas J Steele Thankyou so much! your solution was correct! This has had me
loosing sleep for days! You just made my day =D

Cheers,

Sparrow
 
D

Douglas J. Steele

John actually posted the same solution 2 minutes before me. Must be a faster
typer! <g>
 
Top