Restrict the Time value entered in a text box

  • Thread starter Thread starter Jose
  • Start date Start date
J

Jose

I am having a test box for start time formated in medium time ( i.e.
00:00 AM). How can i restict the time entered by a user so that he/she
should be able to enter the time between 07:00 AM to 03:30 PM.

Thnaks in advance
 
Cancel the BeforeUpdate event procedure of the text box if the time is
outside the range.

Example:

Private Sub Time1_BeforeUpdate(Cancel As Integer)
With Me.Time1
If Not IsNull(.Value) Then
If TimeValue(.Value) < #7:00:00# Or TimeValue(.Value) >
#15:00:00#) Then
Cancel = True
MsgBox "Time1 must be between 7:00 AM to 3:30 PM."
End If
End If
End Sub
End Sub
 

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

Back
Top