473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Validating number input

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 2543
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
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
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" <oi*@vinegar.com> 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
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
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" <oi*@vinegar.com> 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
"PC Datasheet" <no****@nospam.spam> wrote in message news:<oq*****************@newsread2.news.atl.earth link.net>...
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" <oi*@vinegar.com> 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
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:<fe**************************@posting.google. com>...
"PC Datasheet" <no****@nospam.spam> wrote in message news:<oq*****************@newsread2.news.atl.earth link.net>...
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" <oi*@vinegar.com> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brains | last post by:
hello, I am new to access .I am trying to validate a numeric field (Employee number)This field is not auto generated,it is user input field.The data entered in this field should not be less than...
2
by: bildad | last post by:
The following 'book example' of validating input seems to be incomplete. Since it is a beginner's book it may be intentional for simplicity. But I would like to know how to make this program work...
2
by: charleswesley | last post by:
I find myself regularly needing to validate user input as either a) numeric only or b) valid email address format (user@domain.tld) I am assuming that there are regular expressions that can be...
4
by: Materialised | last post by:
Hi all, I am looking for a little help validating a forms input. On the form are key items which I do not wish to be zero length. I have wrote the following function: <script...
17
by: stathis gotsis | last post by:
Hello everyone, I am tying to come up with an elegant way to process some input data that come from a form. When the user hits the 'Submit' button, i want the form to appear again with the...
9
by: chuck | last post by:
I need some help with validating user input. I am writing a C computer program for an intro to C course. Here is the situation. I am creating an application that will do currency conversions. ...
3
by: Louis | last post by:
I have a form with multiple input boxes. I want to validate each input box (and force user to correct it) before allowing user to move to another, either using tab key or a mouse click. I try...
3
by: William Gill | last post by:
I have decided that Since I have to update the processing on many of my forms, I'm going to start them all over from scratch. Before I begin I thought I'd solicit comments on using the PHP regex...
8
rwarren1
by: rwarren1 | last post by:
What is the best way to validate a users input? I need to validate a "Name" entered in a textbox, as well as an enetered "Score". Could someone please help me with this.
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.