Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP with Decimals/Fractions 1

Status
Not open for further replies.

nayfeh

Programmer
Mar 13, 2002
163
0
0
CA
Hi,

Not sure how to handle this. I have an input form with Product Number and Quantity. The underlying table is tbl_Orders. Now, the only field that can be changed is QUANTITY. It's a Long Int.
Now, I have a validation in the text field for Quantity that it must be >= 0. However, I'd like to NOT allow any fractions or decimals...ideally by having a validation (if possible). Right now, ACCESS rounds any decimals entered by the user. What is the best way to do this....AND HOW? Should this be done in the form? Please advise if you can.

Thank you in advance.

TN
 
One way is to trap any extrneous key strokes.
I assume that quantity is always positive.
You can code a trap to allow the user to enter only the charatcters "0" (zero) thru "9"

In the "On Key Press" event for the quantity field on the form enter this code:

If KeyAscii < Asc(&quot;0&quot;) Or KeyAscii > Asc(&quot;9&quot;) Then
KeyAscii = 0
Beep
End If

That's all there is to it.

There will be a beep if the operator enters an invailid character.

If your textbox is called &quot;Quantity&quot; the code will look like this:
Private Sub Quantity_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc(&quot;0&quot;) Or KeyAscii > Asc(&quot;9&quot;) Then
KeyAscii = 0
Beep
End If
End Sub

Good luck [pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top