Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Texas, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Enter hours in 1/4 hour increments only (A2000,SR-1)

    On one of the fields of a form, users input hours. The hours should be in 1/4 hour increments only. However, some users enter .375, etc. Is there a way to force users to use correct increment?

    Thanks,
    El

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enter hours in 1/4 hour increments only (A2000,SR-1)

    According your textbox is named txtTime, put this code in the Before Update of the textbox:
    <pre>Private Sub txtTime_BeforeUpdate(Cancel As Integer)
    Dim intRest As Integer
    If IsNumeric(Me.txtTime) Then
    intRest = Int(Me.txtTime * 100) - Int(Me.txtTime) * 100
    Select Case intRest
    Case 0, 25, 50, 75
    Case Else
    MsgBox "Enter the time rounded to 1/4"
    Cancel = True
    End Select
    Else
    MsgBox "Enter the time rounded to 1/4"
    Cancel = True
    End If
    End Sub</pre>

    Francois

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Location
    Texas, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enter hours in 1/4 hour increments only (A2000,SR-1)

    It works. Thanks!
    Is there a way to cancel the "The value in the field or record violates the validation rule for the record or field..." message that appears after the MsgBox message? In other words, can I have only one message box to pop up instead of two?

    El

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enter hours in 1/4 hour increments only (A2000,SR-1)

    Do you have some validation in the table ? Can it be removed ?
    Francois

  5. #5
    New Lounger
    Join Date
    Mar 2002
    Location
    Texas, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enter hours in 1/4 hour increments only (A2000,SR-1)

    Francois, that did it. Thanks so much.

    El

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •