Help with Time()

ScrmingWhisprs

I <3 Coffee Milk.
Local time
Today, 16:09
Joined
Jun 29, 2006
Messages
156
I've been stuck with this problem for a while now. I'm working on a volunteer tracker database. I have a sign in form that when open, stamps the TimeIn field with Time(). The issue is, sometimes we sign in volunteers a little early, so I'm trying to find a way to stamp the TimeIn field with 6:30PM if the current time is BEFORE 6:30PM.

I received the code below from someone, but it didn't work. TimeIn still stamps the the current time when it's before 6:30PM.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim TimeIn As Date

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

End If
End Sub

All help is appreciated!
Thanks
ScrmingWhisprs
 
Change it to:
Code:
Dim TimeIn As Date

If Time < #6:30:00 PM# Then
   TimeIn = #6:30:00 PM#
Else
   TimeIn = Time()
End If
 
Hello:

Please see enclosed attachment

Regards
Mark
 

Attachments

Hello:

Please see enclosed attachment

Regards
Mark

Mark:

The sample is good, except that he is needing to assign the value to a date/time datatype and your text box is doing text.

My code that I posted, just before your post, will solve that problem for him as it will assign the correct date/time datatype to the time variable.
 
Thanks to both of you!

Both solutions actually work great.

ScrmingWhisprs
 

Users who are viewing this thread

Back
Top Bottom