Connecting Tech Pros Worldwide Help | Site Map

Validating number input

Laurie
Guest
 
Posts: n/a
#1: Nov 13 '05
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
fredg
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Validating number input


On 17 Sep 2004 16:54:58 -0700, Laurie wrote:
[color=blue]
> 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[/color]

Make the field a number datatype.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Salad
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Validating number input


Laurie wrote:[color=blue]
> 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[/color]

See IsNumeric in help.

Ex:
If IsNumeric("123") Then...
x = 123
If IsNumeric(x) Then...
Douglas J. Steele
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Validating number input


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" <oil@vinegar.com> wrote in message
news:rhZ2d.1068$qA6.38@newsread3.news.pas.earthlin k.net...[color=blue]
> Laurie wrote:[color=green]
> > 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[/color]
>
> See IsNumeric in help.
>
> Ex:
> If IsNumeric("123") Then...
> x = 123
> If IsNumeric(x) Then...[/color]


Salad
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Validating number input


Douglas J. Steele wrote:[color=blue]
> Just be aware that things like 123E4 and 543D2 will be found as Numeric by
> the IsNumeric function.
>
> (1230000 and 54300 respectively)
>[/color]

Interesting. I can understand somewhat the E4 thinking the power of.
What is the "D"?
PC Datasheet
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Validating number input


Notice that Doug's example is "D2" ---
2 Decimal places

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource@pcdatasheet.com
www.pcdatasheet.com


"Salad" <oil@vinegar.com> wrote in message
news:V203d.4032$gG4.2655@newsread1.news.pas.earthl ink.net...[color=blue]
> Douglas J. Steele wrote:[color=green]
> > Just be aware that things like 123E4 and 543D2 will be found as Numeric[/color][/color]
by[color=blue][color=green]
> > the IsNumeric function.
> >
> > (1230000 and 54300 respectively)
> >[/color]
>
> Interesting. I can understand somewhat the E4 thinking the power of.
> What is the "D"?[/color]


Laurie
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Validating number input


"PC Datasheet" <nospam@nospam.spam> wrote in message news:<oq03d.5889$n16.3898@newsread2.news.atl.earth link.net>...[color=blue]
> Notice that Doug's example is "D2" ---
> 2 Decimal places
>
> --
> PC Datasheet
> Your Resource For Help With Access, Excel And Word Applications
> resource@pcdatasheet.com
> www.pcdatasheet.com
>
>
> "Salad" <oil@vinegar.com> wrote in message
> news:V203d.4032$gG4.2655@newsread1.news.pas.earthl ink.net...[color=green]
> > Douglas J. Steele wrote:[color=darkred]
> > > Just be aware that things like 123E4 and 543D2 will be found as Numeric[/color][/color]
> by[color=green][color=darkred]
> > > the IsNumeric function.
> > >
> > > (1230000 and 54300 respectively)
> > >[/color]
> >
> > Interesting. I can understand somewhat the E4 thinking the power of.
> > What is the "D"?[/color][/color]

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
user_5701
Guest
 
Posts: n/a
#8: Nov 13 '05

re: Validating number input


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)

lesparke@austarnet.com.au (Laurie) wrote in message news:<fef26cb7.0409200017.147bfc02@posting.google. com>...[color=blue]
> "PC Datasheet" <nospam@nospam.spam> wrote in message news:<oq03d.5889$n16.3898@newsread2.news.atl.earth link.net>...[color=green]
> > Notice that Doug's example is "D2" ---
> > 2 Decimal places
> >
> > --
> > PC Datasheet
> > Your Resource For Help With Access, Excel And Word Applications
> > resource@pcdatasheet.com
> > www.pcdatasheet.com
> >
> >
> > "Salad" <oil@vinegar.com> wrote in message
> > news:V203d.4032$gG4.2655@newsread1.news.pas.earthl ink.net...[color=darkred]
> > > Douglas J. Steele wrote:
> > > > Just be aware that things like 123E4 and 543D2 will be found as Numeric[/color][/color]
> by[color=green][color=darkred]
> > > > the IsNumeric function.
> > > >
> > > > (1230000 and 54300 respectively)
> > > >
> > >
> > > Interesting. I can understand somewhat the E4 thinking the power of.
> > > What is the "D"?[/color][/color]
>
> 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[/color]
Laurie
Guest
 
Posts: n/a
#9: Nov 13 '05

re: Validating number input


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
Closed Thread


Similar Microsoft Access / VBA bytes