Validation rule woes (1 Viewer)

pungentSapling

NeedHotSauce?
Local time
Today, 02:05
Joined
Apr 4, 2002
Messages
116
I am trying to create a validation rule on a text box so that the user can only enter a number that is in a .5 increment.

ie: 1.5 is OK
2.0 is ok
2.6 is NOT OK

Here is what I have in the validation rule property field....
Like "*.0" Or Like "*.5"
but it will only accept numbers that end in .5..... if the number ends in .0 it rejects it

any ideas ....

Thanks
Pungent
 

ghudson

Registered User.
Local time
Today, 02:05
Joined
Jun 8, 2002
Messages
6,195
I believe that you will have to use the AfterUpdate event of the text box to test the value keyed. You can use the Right() function to test the last digit within the value keyed.
 

pungentSapling

NeedHotSauce?
Local time
Today, 02:05
Joined
Apr 4, 2002
Messages
116
Thanks for the input. I had trouble with the Right() function when the entry ended in #.0 it was not picking up the 0 it would pick up the first number to the left of the decimal point.

I went with using the mod operator to determine if the value was divisible by .5:

Private Sub CheckMod()
'This sub uses the Mod operator to check if the hours entered are divisible by .5
'Goal: to ensure hours are entered in .5 hour increments
Dim dblMod As Double
Dim dblHrs As Double

dblHrs = Me.BillableHours.Value * 10
dblMod = dblHrs Mod 5

If dblMod = 0 Then
MsgBox "Good Entry"
Else
MsgBox "Invalid entry... Use .5 Hr Increments Only!"
Me.BillableHours.Value = 0
Me.BillableHours.SetFocus
End If

End Sub


Thanks for the input !

Pungent
 

Users who are viewing this thread

Top Bottom