STRING LENGHT

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

Guest

Is there any possibility to sort a column in Access by string lenght, or
filter all longer than 30 characters?
 
Sure.

Create a query, and add as many fields from the table as you care about.

Add a computed field by typing something like the following into a blank
cell on the Field row in the query builder:

StringLength: Len([MyTextField])

(replace "MyTextField" with the name of the actual field)

To sort by string length, select either Descending or Ascending in the Sort
row underneath the computed field you just added.

Not sure if by "filter all longer than 30 characters" you mean you only want
to see those that are longer than 30 characters, or you want to eliminate
those that are longer than 30 characters. For the former, put > 30 in the
Criteria row under the computed field you just added. For the former, put <=
30 as the Criteria.

By the way, if you uncheck the "Show" box under the computed field you just
added, you won't see the field length in the query results, but the sorting
and filtering will still work.
 
To sort it by this, add a new column of =Len([field name])
then sort by it.
 
SELECT ..., Len(Thefield) AS LenOfField FROM ...
[WHERE Len(Thefield) > 30]
ORDER BY LenOfField

Pieter
 
oops. forget the "="

In a query it would be more like...

NewField: Len([CurrentField])


--
Rick B



Rick B said:
To sort it by this, add a new column of =Len([field name])
then sort by it.

--
Rick B



Itjentije said:
Is there any possibility to sort a column in Access by string lenght, or
filter all longer than 30 characters?
 

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

Back
Top