Counting characters in a field

G

Guest

I need a query which will count the total number of incidences of specified
characters in a field. I then need the query to report the total number of
records for which this number is greater than a specified value.

For example, this morning I need to count the total number of incidences of
the characters *, A, B and C in a field called Results. I then need to
return and count the record if the total number of incidences is greater than
4. So, using actual examples, a field with a value of A*ABCEFG (5 incidences)
would count towards the total; GGUCC*BF (4 incidences)would not.

Any help would be appreciated.

Jim Jones
 
D

Douglas J. Steele

See whether the following, typed as a computed field in an empty cell of
your query, works for you.

Occurrences: Len([Results]) - Len(Replace(Replace(Replace(Replace([Results],
"*", ""), "A", ""), "B", ""), "C",""))

You must be using Access 2000 or later to be able to use the Replace
function (and you must have all of the service packs installed for Access
2000)
 

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

Similar Threads


Top