Only numbers

W

Wynand Wessels

Hi, im very new to access, the problem i have is that i dont know how to do a
criteria in the query:
I have a tabel, one of the fields is a text field
In the text field i have numbers
The reason why its a text field is because i also have words in the field
What i would like to do:
draw a query wher i only call for records that have only a number in that
field, the number must be only 9 carracters long, and display only that in
report

Can someone help please

Regards
Wynand
 
J

John Spencer (MVP)

Use criteria in a query that is like the following

Field: YourTextField
Criteria: Like "#########"

Alternative standard ANSI-compliant SQL criteria
Field: YourTextField
Criteria: Like "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
M

Marshall Barton

Hi, im very new to access, the problem i have is that i dont know how to do a
criteria in the query:
I have a tabel, one of the fields is a text field
In the text field i have numbers
The reason why its a text field is because i also have words in the field
What i would like to do:
draw a query wher i only call for records that have only a number in that
field, the number must be only 9 carracters long, and display only that in
report


Or, if the numbers are not all the same number of digits:

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

Wynand Wessels

Hi John
Thanks for your help, but its still not giving me what i want
let me re explain
I have a field "text field" in that field i have text, some of the text is
numbers and some records have text and numbers in the field e.g

" hi there, my number is 0824509608"
"0824509608"
"0825133903"
"sms me to 0824137895"

This is the text in the field on 4 records
i would like to do query and draw only the fields that have " 0824509608"
and 0825133903" if a field have text in, it must not be part of my query

hope you understand
many thanks
Wynand

John Spencer (MVP) said:
Use criteria in a query that is like the following

Field: YourTextField
Criteria: Like "#########"

Alternative standard ANSI-compliant SQL criteria
Field: YourTextField
Criteria: Like "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Wynand said:
Hi, im very new to access, the problem i have is that i dont know how to do a
criteria in the query:
I have a tabel, one of the fields is a text field
In the text field i have numbers
The reason why its a text field is because i also have words in the field
What i would like to do:
draw a query wher i only call for records that have only a number in that
field, the number must be only 9 carracters long, and display only that in
report

Can someone help please

Regards
Wynand
 
W

Wynand Wessels

Hi Marshall

Please see my post to Jhon

Thanks

Wynand


Marshall Barton said:
Hi, im very new to access, the problem i have is that i dont know how to do a
criteria in the query:
I have a tabel, one of the fields is a text field
In the text field i have numbers
The reason why its a text field is because i also have words in the field
What i would like to do:
draw a query wher i only call for records that have only a number in that
field, the number must be only 9 carracters long, and display only that in
report


Or, if the numbers are not all the same number of digits:

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

John Spencer (MVP)

No, I don't understand what you want.

This criteria will return all records that have 0824509608 anywhere in the field.
Field: YourField
Criteria: Like "*0824509608*"

This criteria will return any record that has 9 digits in a row anywhere in
the field (By the way 0824509608 is ten digits in length)
Field: YourField
Criteria: Like "*#########*"

This criteria will return any record that has exactly 9 digits. IF you want
exactly ten digits then you need to add another # into the criteria.
Field: YourTextField
Criteria: Like "#########"

This criteria will find any record that has at 9 or 10 digits in the field
Field: YourTextField
Criteria: Like "#########" or Like "##########"

Another way to get a record that ONLY has numbers in it is the following -
this would return a field with 1 to 100 digits in it as long as digits were
the only characters in the field. It basically says is there any character in
the field that is not a digit. If so, then the field meets the like criteria.
But the NOT in front of the LIKE operator then says reject the matches.
Field: YourTextField
Criteria: NOT Like "*[!0-9]*"

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Wynand said:
Hi John
Thanks for your help, but its still not giving me what i want
let me re explain
I have a field "text field" in that field i have text, some of the text is
numbers and some records have text and numbers in the field e.g

" hi there, my number is 0824509608"
"0824509608"
"0825133903"
"sms me to 0824137895"

This is the text in the field on 4 records
i would like to do query and draw only the fields that have " 0824509608"
and 0825133903" if a field have text in, it must not be part of my query

hope you understand
many thanks
Wynand

John Spencer (MVP) said:
Use criteria in a query that is like the following

Field: YourTextField
Criteria: Like "#########"

Alternative standard ANSI-compliant SQL criteria
Field: YourTextField
Criteria: Like "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Wynand said:
Hi, im very new to access, the problem i have is that i dont know how to do a
criteria in the query:
I have a tabel, one of the fields is a text field
In the text field i have numbers
The reason why its a text field is because i also have words in the field
What i would like to do:
draw a query wher i only call for records that have only a number in that
field, the number must be only 9 carracters long, and display only that in
report

Can someone help please

Regards
Wynand
 
M

Marshall Barton

Wynand said:
Please see my post to Jhon


Both John's and my suggestions will do what you originally
asked. Your second explanation said the same thing again so
I have no idea what about our replies fails to meet your
needs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top