| | |
|
|
|
Text Totals |
| message from =?Utf-8?B?dGhlaGVkZ2Vob2c0Mg==?= on 3 Jun 2004 |
I am trying to total up the number of times certain words are used in a column of my Access table. I can figure out how to total numbers, but not how to count the number of times a word appears. I've tried using a report and a query, but I can't figure out a way to count text.
Thanks,
Ashley
|
| Arvin Meyer replied to =?Utf-8?B?dGhlaGVkZ2Vob2c0Mg==?= on 3 Jun 2004 |
column of my Access table. I can figure out how to total numbers, but not
how to count the number of times a word appears. I've tried using a report
and a query, but I can't figure out a way to count text.
This code will count the number of occurances of a string within a string.
It does not differentiate between "the" and "them" when searching for "the".
You can use it in a query column like:
Expr1: CountOccurrences([FieldName], "the", 3)
The intCount argument is the number of characters in the word you are
looking for.
Public Function CountOccurrences(StringToParse As String, _
CharToFind As String, intCount As Integer) As Integer
' Counts occurrences of a character in a string
' Arvin Meyer - 12/14/1999
On Error Resume Next
Dim iLoop As Integer
Dim iFound As Integer
iFound = 0
For iLoop = 1 To Len(StringToParse)
If Mid(StringToParse, iLoop, intCount) = CharToFind Then
iFound = iFound + 1
End If
Next iLoop
CountOccurrences = iFound
End Function
|
| Jim/Chris replied to =?Utf-8?B?dGhlaGVkZ2Vob2c0Mg==?= on 3 Jun 2004 |
In a new control in a report
=Sum(Abs([fieldname]="yourvalue"))
In a totals query
Total:Sum(Abs([fieldname]="yourvalue"))
Jim
are used in a column of my Access table. I can figure out
how to total numbers, but not how to count the number of
times a word appears. I've tried using a report and a
query, but I can't figure out a way to count text.
|
|
Archived message: Text Totals (Microsoft Access Forms)