field validation

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
 
G

Guest

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
 
J

Jeff Boyce

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
 

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

Similar Threads


Top