Thanks Brendan
I should have expanded my search a bit.
I guess a custom function is the way to go, but I was also able to get
the
correct results by combining the Len() and replace functions as follows:
Len([Account])-Len(Replace([Account],".",""))
This works, but as I said, I like your function better.
Cheers!
TK
Brendan Reynolds said:
Here's what I posted in reply to the same question in
microsoft.public.access two days ago ...
Nothing built-in, no, but you can do it with a few lines of VBA ...
Public Function CountInString(ByVal strCountIn As String, ByVal
strCountThis
As String) As Long
Dim lngLoop As Long
Dim lngCount As Long
For lngLoop = 1 To Len(strCountIn)
If Mid$(strCountIn, lngLoop, Len(strCountThis)) = strCountThis
Then
lngCount = lngCount + 1
End If
Next lngLoop
CountInString = lngCount
End Function
? countinstring ("this is some text","is")
2
--
Brendan Reynolds (MVP)
Is there an easy way to count the occurances of a specific character
in a
string?
For instance, if a table contains a list of account and subaccount
codes
delimited with periods such as: "SALES.41400.27" I would like a
formula
that
counts the number of periods in the total string, (2 in this case).
TIA
TK