Time data entry restriction

G

Gina Whipp

All,

I am trying to restrict TimeOut field to the times indicated below.
Obviously it is not working and I can't see why. The formating on that
field is Medium Time.

If Me.txtTimeOut >= "12:00 AM" And Me.txtTimeOut <= "05:00 AM" Then
MsgBox "You MUST enter a time between 6:00 am and 11:59 PM!",
vbInformation, "AM/PM"
Me.txtTimeOut = Null
End If
Exit Sub


Thanks in Advance!
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II
 
M

Marshall Barton

Gina said:
I am trying to restrict TimeOut field to the times indicated below.
Obviously it is not working and I can't see why. The formating on that
field is Medium Time.

If Me.txtTimeOut >= "12:00 AM" And Me.txtTimeOut <= "05:00 AM" Then
MsgBox "You MUST enter a time between 6:00 am and 11:59 PM!",
vbInformation, "AM/PM"
Me.txtTimeOut = Null
End If


Literal date/time value must be enclosed in # signs, not
quotes:

If Me.txtTimeOut >= #12:00 AM# And Me.txtTimeOut <= #05:00
AM# Then
 
J

Jim Burke in Novi

If you want times to be limited to >= 6 AM use

If Me.txtTimeOut < #06:00:00 AM# Then
 
M

Marshall Barton

Gina said:
Can you tell why entering 10:15 AM generates my message?


I can't reproduce that effect.

Are you sure the field (in the table) is a Date type field?
 
D

david

I hate it when I see 12:00 AM.

Not because I'm picky, just because there is no agreement, and
no reference. I have to figure it out every time I see that. One of
my Internet Providers has unrestricted Access from 12:00 PM to
12:00 AM. What does that mean? Can you look it up on the
Internet? Good luck at that: you have to figure it out.

In this case, I already know how time is represented in Access,
so I could just say

If Me.txtTimeOut <= #05:00 AM# Then

Conversely, if I didn't know how time was represented in Access,
I would certainly never do time comparisons at all.

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top