"Rick Brandt" <(E-Mail Removed)> wrote in message
news:QCsqh.1157$(E-Mail Removed)...
> Robert wrote:
>> rick, the field is imported from an excell spread sheet monthly. the
>> field is not utlized in any way except for the counting of the
>> groups. can we count the "," (and add 1) instead of creating a split
>> with an array for each value?
>
> The Split() is just one example of determining how many values there are
> and thus how many commas there are. You can also create a function that
> loops through all the characters and counts the commas...
>
> Function CommaCount(FieldIn As String) As Byte
>
> Dim i As Byte
>
> For i = 1 To Len(FieldIn)
> If Mid(FieldIn, i, 1) = "," Then CommaCount = CommaCount + 1
> Next i
Probably simpler to check the length of the string, replace all commas in
the string with zero-length strings and see how much shorter the string it.
Function CommaCount(FieldIn As String) As Byte
CommaCount = Len(FieldIn) - Len(Replace(FieldIn, ",", vbNullString))
Exit Function
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)