how do i make my criteria for a query where a field = x character.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how do i make my criteria for a query "where [field1] = x characters in
length"? I figure it has to do with the Len function but i cant figure out
the syntax. Thank you for any help.
 
This is from Access help

The following table lists examples of expressions that use the Len function
to calculate the length of a text value.

You can use these expressions in calculated controls (calculated control: A
control that is used on a form, report, or data access page to display the
result of an expression. The result is recalculated each time there is a
change in any of the values on which the expression is based.) on forms,
reports, and data access pages (data access page: A Web page, published from
Access, that has a connection to a database. In a data access page, you can
view, add to, edit, and manipulate the data stored in the database. A page
can also include data from other sources, such as Excel.).

Expression Description
=Len("Hello") Displays the number of characters in the string. This
expression returns the value 5.
=Len("Hello World") Displays the number of characters, including spaces.
This expression returns the value 11.
=Len([FirstName]) Returns the number of characters in the FirstName field.

You can use these expressions in a calculated field in a query.

Expression Description
MyCount: Len("Hello") Displays in the MyCount field the number of characters
in the string "Hello."
MyCount: Len([FirstName]) Displays in the MyCount field the number of
characters in the FirstName field.
 
If you use the SQL View, you can add the WHERE clause like:

SELECT ...
FROM [YourTable]
WHERE Len([Field1]) = x

If you are more comfortable with the QBE grid, go to the next empty column
and:

* in the Field row, enter

LengthOfField1: Len([Field1])

* In the Show row, uncheck the Show CheckBox

* In the criteria row, enter x

Either way, the Query should do what you want regarding selection of records
....
 
Back
Top