"Lars Brownies" <(E-Mail Removed)> wrote in message
news:hg8h15$2rip$(E-Mail Removed)...
> In VBA I need to check whether the current time is after 8 in the evening
> but before 4 in the morning. I looked at the time methods but I can't
> figure out how to do this check. Can someone point me in the right
> direction?
By "current time", do you mean the time of day as reported by the system
clock? If so, try this:
Dim dtTimeNow As Date
dtTimeNow = Time()
If (dtTimeNow >= #8:00 PM#) Or (dtTimeNow < #4:00 AM#) Then
' The time is between 8 PM and 4 AM
Else
' It isn't.
End If
Notice that I have assumed that "after 8 in the evening" includes the time
of 8:00 PM, but "before 4 in the morning" does *not* include the time of
4:00 AM. That may or may not be what you had in mind. If it's not, you can
modify the comparison operators in the If statement.
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)