input only numbers

  • Thread starter Thread starter adriany
  • Start date Start date
A

adriany

i have textbox and i only want user to enter numbers not
char.

anyway to only accept numbers not letters
 
Try this:

Select Case KeyAscii(KeyAscii as Integer)
Case 48 to 57 'numbers 0 through 9
Case 8 'allows backspace
Case Else
KeyAscii = 0
End Select
 
adriany said:
i have textbox and i only want user to enter numbers not
char.

anyway to only accept numbers not letters

Lots of ways. If the text box is bound to a numeric field
or if it has a numeric Format, Access will refuse to accept
a non-numeric entry. No Code required.

If you want to insist on the ten digits without +-. etc
characters that are part of some numbers, then set the text
box's or the table field's Validation Rule to:

Not Like "*[!0-9]*"

and you can specify any validation message you like.
 
Back
Top