Time() Help

ScrmingWhisprs

I <3 Coffee Milk.
Local time
Today, 04:17
Joined
Jun 29, 2006
Messages
156
I have a sign in form for a volunteer tracker I am working on, which has a TimeIn field that is stamped with the current time using Time(). However, our nights of operation don't start until 6:30PM. I would like to have the TimeIn be stamped for 6:30PM if they are signing in BEFORE 6:30PM. Then after 6:30, TimeIn is stamped normally with Time().

Can anyone help with this one?
Thanks
ScrmingWhisprs
 
I'd probably use a Before Update event for the form; in the before update, check if the time() is before 6:30, then replace the value with 6:30.

HTH.
 
I would go with what Banana has put.

Use:

Dim TimeIn As Date

If Time() < "18:30" Then
TimeIn = "18:30"
Else
TimeIn = Time()

End If

You can get away with the Text part as Access will evaluate it as a Time.

Cheers,
 
That sounds to me like it would work, but it didn't.
FYI, the TimeIn field is formatted as Long Time (i.e. 6:25:10 PM). Could that be an issue?
Is the Before Update event of the form the correct place to put it?

Thanks
ScrmingWhisprs
 
Yes, it's right place. I'm not familiar with time data type, unforuntately, so maybe someone else can enlighten you.

But it would be also helpful to post exactly what happened instead of saying "didn't work". Did you get an error message or did Access ignore the validation and persisted with the value entered or?
 
Sorry.
No, I didn't get an error message. Access ignored it. It stamped it with the current time.

ScrmingWhisprs
 

Users who are viewing this thread

Back
Top Bottom