question about running a certain query in access

J

joe_G

Hello,

I have a database of over 10,000 part numbers that are six characters
long and should be in this format: XXXXXX; however, I noticed many
records in the table as XX XXXX. The part numbers are any letter or
number combination and I'm just using the Xs as an example. Basically,
what query can I run in access to find all instances of records in the
format of XX XXXX
 
A

Allen Browne

Create a query. In the Criteria row under this field, enter:
Like "?? ????"

That will locate a space in the 3rd position.

To locate a space anywhere in the field, use:
Like "* *"
 
T

Tom van Stiphout

On Sat, 18 Jul 2009 20:36:52 -0700 (PDT), joe_G <[email protected]>
wrote:

It should be impossible to enter XX XXXX part numbers, since you
smartly created that field as a Text(6), and set a validation rule on
that field: Len(myField) = 6
OK, to find the offending ones (before you do change that field size)
try this:
(find any record with length not 6)
select * from myTable
where Len(myField) <> 6

or:
(find any record with <space> in the third position)
select * from myTable
where Mid$(myField,3,1) = " "

or:
(find any record with a <space>
select * from myTable
where Length(myField) like "* *"

(of course you replace myObjectNames with yours)

-Tom.
Microsoft Access MVP
 

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