Find Spaces

G

Garry

Hi all

I have a field that contains a ten character ID.

How can I find all fields who's ID contains a blank space anywhere in the
field.

Many thanks in advance, Garry

--
 
R

Rick B

I think you would build a query with the following in the criteria...

Like "*" & " " & "*"
 
P

Per Larsen

Rick said:
I think you would build a query with the following in the criteria...

Like "*" & " " & "*"

And why not just do it the easy way:

Like '* *'

(or Like "* *" if you prefer, but single apostrophes is the correct char to use in 'Like' tests)

Regards
PerL
 
V

Van T. Dinh

AFAIK, Access accepts both single-quote and double-quote as String delimiter
....

Try:

Like "* *"

and you find it works exactly the same.

HTH
Van T. Dinh
MVP (Access)
 
P

Per Larsen

Van said:
AFAIK, Access accepts both single-quote and double-quote as String delimiter
...

Try:

Like "* *"

and you find it works exactly the same.

HTH
Van T. Dinh
MVP (Access)

That's why I did show both ways also. However, in the Access help examples you will find that
single-quotes are preferred, as in these from 'WHERE Clause Example (Microsoft Access)':
/
"To try the following examples in Microsoft Access, first create a new query in the Northwind sample database. Close the Show Table dialog box without specifying a table or query. Switch to SQL view, paste an individual example into the SQL window, and run the query.
The following example selects the LastName and FirstName fields of each record in which the last name is King:

SELECT LastName, FirstName FROM Employees
WHERE LastName = 'King';

The next example selects the LastName and FirstName fields for employees whose last names begin with the letter S:

SELECT LastName, FirstName FROM Employees
WHERE LastName Like 'S*';

<snip>...

The next example selects all products whose names fall in alphabetic order between "Cha" and "Out", inclusive. It doesn't retrieve "Outback Lager" because "Outback Lager" follows "Out" and therefore is outside the specified range.

SELECT ProductName, UnitPrice FROM Products
WHERE ProductName Between 'Cha' And 'Out';
/

Regards
PerL
 
Top