424,950 Members | 989 Online
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

# Validating number input

 P: n/a Hi All This seems very simple but how would you validate that a user has entered just numbers into a form's textbox. That is 1234 is good while Wer234 and 234ddd is bad. I would prefer to use VBA if possible Thanks Laurie Nov 13 '05 #1
8 Replies

 P: n/a On 17 Sep 2004 16:54:58 -0700, Laurie wrote: Hi All This seems very simple but how would you validate that a user has entered just numbers into a form's textbox. That is 1234 is good while Wer234 and 234ddd is bad. I would prefer to use VBA if possible Thanks Laurie Make the field a number datatype. -- Fred Please only reply to this newsgroup. I do not reply to personal email. Nov 13 '05 #2

 P: n/a Laurie wrote: Hi All This seems very simple but how would you validate that a user has entered just numbers into a form's textbox. That is 1234 is good while Wer234 and 234ddd is bad. I would prefer to use VBA if possible Thanks Laurie See IsNumeric in help. Ex: If IsNumeric("123") Then... x = 123 If IsNumeric(x) Then... Nov 13 '05 #3

 P: n/a Just be aware that things like 123E4 and 543D2 will be found as Numeric by the IsNumeric function. (1230000 and 54300 respectively) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Salad" wrote in message news:rh***************@newsread3.news.pas.earthlin k.net... Laurie wrote: Hi All This seems very simple but how would you validate that a user has entered just numbers into a form's textbox. That is 1234 is good while Wer234 and 234ddd is bad. I would prefer to use VBA if possible Thanks Laurie See IsNumeric in help. Ex: If IsNumeric("123") Then... x = 123 If IsNumeric(x) Then... Nov 13 '05 #4

 P: n/a Douglas J. Steele wrote: Just be aware that things like 123E4 and 543D2 will be found as Numeric by the IsNumeric function. (1230000 and 54300 respectively) Interesting. I can understand somewhat the E4 thinking the power of. What is the "D"? Nov 13 '05 #5

 P: n/a Notice that Doug's example is "D2" --- 2 Decimal places -- PC Datasheet Your Resource For Help With Access, Excel And Word Applications re******@pcdatasheet.com www.pcdatasheet.com "Salad" wrote in message news:V2*****************@newsread1.news.pas.earthl ink.net... Douglas J. Steele wrote: Just be aware that things like 123E4 and 543D2 will be found as Numeric by the IsNumeric function. (1230000 and 54300 respectively) Interesting. I can understand somewhat the E4 thinking the power of. What is the "D"? Nov 13 '05 #6

 P: n/a "PC Datasheet" wrote in message news:... Notice that Doug's example is "D2" --- 2 Decimal places -- PC Datasheet Your Resource For Help With Access, Excel And Word Applications re******@pcdatasheet.com www.pcdatasheet.com "Salad" wrote in message news:V2*****************@newsread1.news.pas.earthl ink.net... Douglas J. Steele wrote: Just be aware that things like 123E4 and 543D2 will be found as Numeric by the IsNumeric function. (1230000 and 54300 respectively) Interesting. I can understand somewhat the E4 thinking the power of. What is the "D"? Thanks for all the replies. Just after posting the message I realised that defining the datatype was all I needed however the comment on IsNumeric took me by surprise. It is amazing what a seemly simple question can raise. Thanks Laurie Nov 13 '05 #7

 P: n/a If the only thing that field can accept is numbers only, use an InputMask on the field. Defining the datatype will still allow them to enter letters, but I think it will throw an error when they leave that field if they typed in something that the datatype in the table won't allow. (such as a letter in a Number datatype field) le******@austarnet.com.au (Laurie) wrote in message news:... "PC Datasheet" wrote in message news:... Notice that Doug's example is "D2" --- 2 Decimal places -- PC Datasheet Your Resource For Help With Access, Excel And Word Applications re******@pcdatasheet.com www.pcdatasheet.com "Salad" wrote in message news:V2*****************@newsread1.news.pas.earthl ink.net... Douglas J. Steele wrote: > Just be aware that things like 123E4 and 543D2 will be found as Numeric by > the IsNumeric function. > > (1230000 and 54300 respectively) > Interesting. I can understand somewhat the E4 thinking the power of. What is the "D"? Thanks for all the replies. Just after posting the message I realised that defining the datatype was all I needed however the comment on IsNumeric took me by surprise. It is amazing what a seemly simple question can raise. Thanks Laurie Nov 13 '05 #8

 P: n/a Hi Yes a datatype was not the answer so I decided to redesign the database and use a text field in place of the number field I was trying to validate. This ended up being a much better solution overall. Cheers Laurie Nov 13 '05 #9

### This discussion thread is closed

Replies have been disabled for this discussion.