validation rule

hazell

Registered User.
Local time
Today, 06:42
Joined
Jul 9, 2013
Messages
54
Hi All,
I have a number field and I want the numbers all to be either whole numbers or to end in .25, .5 or .75.

How do I write a validation rule that ensures that only these numbers are entered?
thanks
Hazell
 
There are probably better ways, but until someone else comes along, you could try:
Code:
  Dim i As Integer
  Dim sng As Single
  sng = CSng(Me.[COLOR="red"]YourCtrlName[/COLOR])
  i = Me.[COLOR="Red"]YourCtrlName[/COLOR]
  If Abs(sng - i) <> 0.25 And Abs(sng - i) <> 0 And Abs(sng - i) <> 0.5 And Abs(sng - i) <> 0.75 Then
    Cancel = True
  End If
in the Before Update of your control.
 
I will wait for some time and then post a solution, in my head it is clunky.

EDIT: Posted at the same time Bob posted.
 
Check if Number*100 can be divided by 25

IIf((Number*100) MOD 25 = 0, "OK", "Not OK")
 
This is something that can be at the table level.

Set the Validation to
In (0,0.25,0.5,0.75)
 

Users who are viewing this thread

Back
Top Bottom