I may not have said that correctly. Here goes...
User inputs time into a field by entering or using KeyPress event to
increase/decrease time in 15 minute increments.
******* code for keypress event
Dim strInterval As String
strInterval = "n"
Select Case KeyAscii
Case 43 'plus key
KeyAscii = 0
Screen.ActiveControl = DateAdd(strInterval, 15, Screen.ActiveControl)
Case 45 'minus key
KeyAscii = 0
Screen.ActiveControl = DateAdd(strInterval, -15, Screen.ActiveControl)
End Select
******* end code
My conrtrol [txtDC7Start] is formatted "h:nn a/p" and defaults to "8:00 a".
Its control source is [DC7Start]. Presently, the user can +/- or enter the
time. I want to restrict their input to between 6 am and 10 pm. I am having
trouble with the time format combined with limitation.
Can someone suggest a simple method to accomplish this limitation? The

Signature
Thanks for your help,
Chris
John W. Vinson - 28 Feb 2007 21:12 GMT
>I may not have said that correctly. Here goes...
>
[quoted text clipped - 19 lines]
>
>Can someone suggest a simple method to accomplish this limitation? The
The format shouldn't have anything to do with it. If you want to
constrain the result to a range of times, what do you want to happen
when the user gets outside the range?
Try this:
Dim strInterval As String
Dim vTime As Variant
vTime = Timevalue(Screen.ActiveControl)
strInterval = "n"
Select Case KeyAscii
Case 43 'plus key
KeyAscii = 0
If vTime >= #10:00pm# Then
Beep
Else
vTime = DateAdd(strInterval, 15,vTime)
End If
Case 45 'minus key
KeyAscii = 0
If vTime <= #6:00am# Then
Beep
Else
vTime = DateAdd(strInterval, -15, vTime)
End If
End Select
Screen.ActiveControl = vTime
John W. Vinson [MVP]
Chris - 28 Feb 2007 21:51 GMT
Hmmm...what did I want? What you gave me. Perfecto!
Once again, the gurus come through for the riff raff.
Thanks, John.

Signature
Chris
> >I may not have said that correctly. Here goes...
> >
[quoted text clipped - 49 lines]
>
> John W. Vinson [MVP]