Counting Text Within a Field

  • Thread starter Pris via AccessMonster.com
  • Start date
P

Pris via AccessMonster.com

Hello,

I have a table called “tblWorkLogâ€.
Is there an expression that will count the number of times “Dry Runâ€, “M Dry
Runâ€, “T Dry Runâ€, and “VA Dry Run“ appear in the “Types†field and display
the total in a numerical value in a report textbox and also count the number
of times “F Stand-byâ€, “LF Stand-byâ€, “OR Stand-byâ€, and “Stand-by†appear in
the “Types†and display the total in numerical value in a separate textbox in
the same report.

Thank You
 
G

Guest

Your title wasn't entirely accurate! I thought you meant count the number of
characters within a string.

To answer your question, use a "totals" query ("group by" and "count"). Then
you can use that query for the report.
 
F

fredg

Hello,

I have a table called ´tblWorkLog¡.
Is there an expression that will count the number of times ´Dry Run¡, ´M Dry
Run¡, ´T Dry Run¡, and ´VA Dry Run´ appear in the ´Types¡ field and display
the total in a numerical value in a report textbox and also count the number
of times ´F Stand-by¡, ´LF Stand-by¡, ´OR Stand-by¡, and ´Stand-by¡ appear in
the ´Types¡ and display the total in numerical value in a separate textbox in
the same report.

Thank You

Assuming that, for example, the word "dry" or the word "run" might
appear in the string without being part of one of the wanted phrases
(i,e, "Today I took a dry run down the trail.") , here's one way to
count the instances of one of them in a Query.

CountInString: (Len([FieldName])-Len(Replace([FieldName],"Dry
Run","")))/7

The /7 part is whatever the number of characters in the search string
(i.e. "Dry Run") is.

You might try running them together if you just want one combined
total.

CountInString: ((Len([FieldName])-Len(Replace([FieldName],"Dry
Run","")))/7) + ((Len([FieldName])-Len(Replace([FieldName],"M Dry
Run","")))/9) + etc....
 

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