Validate number to be in incremental of .5

S

Silvio

I have an unbounded text box that users use to enter worked hours and a
button that will transfer the value to a control. How can I validate the
number in the unbounded text box to make sure the numbers are of increment of
..5? In few words, users can enter from 1/2 hour to full hours and 1/2. An
example of a valid number would be something like: .5, 1, 1.5, 2, 2.5, 3, 3.5
and so on - an example of invalid number would be something like .3, 1.2, 2.8
and so on.

Thank you,
Silvio
 
S

Silvio

Thanks, can you be more specific? My control's name is TxHours.

The syntax should be something like:
if me.TxHours <> valid number then
msgbox "please enter a number in the increment of .5"
Exit Sub
End If
 
S

Stalin

Thanks, can you be more specific? My control's name is TxHours.

The syntax should be something like:
if me.TxHours <> valid number then
msgbox "please enter a number in the increment of .5"
Exit Sub
End If

raskew via AccessMonster.com said:
Try a variation of this:
y = 3.5
? iif(int(y/0.5)= y/0.5, "OK", "Error")
OK
y = 3.4
? iif(int(y/.5)= y/0.5, "OK", "Error")
Error
HTH - Bob
You need to use VAL to ensure the correct conversion to Numeric value
before using the suggested formula.

Or if you know that a finitie amount of hours can be used (0.5-8) just
make it a combo box and limit the selections to only those values.
 

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

Top