field validation

  • Thread starter Thread starter Jesper F
  • Start date Start date
J

Jesper F

I need to restrict the user to enter the numbers in a field such that only
numbers like these are accepted:
0
0.25
0.5
0.75
....
4.5
4.75
5.00

(doesn't matter with the decimals but) the rule being that the number MOD
0.25 = 0
and a max of 10.

Can this be entered directly into the "validation rule" property?

Thanks

/ Jesper
 
I would do it in the Before Update event of the field:

Private Sub TheField_BeforeUpdate(Cancel As Integer)

If Me.TheField > 10 Or ((Me.TheField *100) mod 25) <> 0 Then
Cancel = True
MsgBox "Not A Valid Value"
End If
End Sub
 
Jesper

If you need to constrain the values that can be entered, and if you have a
limited number of value choices, consider adding the valid values to a
lookup table and using a combo box...

Just a thought...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Back
Top