Hi MG,
I'm sorry I brought it up.
I had a function
Public Function fWordCount(pMemo As Variant) As Long
On Error GoTo Err_fWordCount
Dim arrWords As Variant, i As Long, lngCount As Long
If Len(Trim(pMemo & "")) = 0 Then
fWordCount = 0
Exit Function
End If
lngCount = 0
pMemo = Replace(pMemo, vbCr, " ", 1, -1, vbTextCompare)
pMemo = Replace(pMemo, vbLf, " ", 1, -1, vbTextCompare)
pMemo = Replace(pMemo, vbTab, " ", 1, -1, vbTextCompare)
arrWords = Split(pMemo, " ", -1, vbTextCompare)
For i = 0 To UBound(arrWords)
If Len(arrWords(i) & vbNullString) > 0 Then
lngCount = lngCount + 1
End If
Debug.Print i & ": " & arrWords(i) & ";" & lngCount
Next i
fWordCount = lngCount
Exit_fWordCount:
Exit Function
Err_fWordCount:
MsgBox Err.Description
Resume Exit_fWordCount
End Function
and ran it against a "this-and-that" db
that had 2829 records with a memo
field "FullLine" that could be quite large.
SELECT tbl_MailDBX.ID, tbl_MailDBX.Topic,
fWordCount([FullLine]) AS WordCount
FROM tbl_MailDBX
WHERE (((tbl_MailDBX.ID)=1))
ORDER BY tbl_MailDBX.Topic;
This is only working on one record
and when I run it, the Debug.Print
gives me one cycle.
If I try to sort on the calc field
SELECT tbl_MailDBX.ID, tbl_MailDBX.Topic,
fWordCount([FullLine]) AS WordCount
FROM tbl_MailDBX
WHERE (((tbl_MailDBX.ID)=1))
ORDER BY fWordCount([FullLine]);
the Debug.Print shows 2 "cycles."
Sorting like
SELECT tbl_MailDBX.ID, tbl_MailDBX.Topic,
fWordCount([FullLine]) AS WordCount
FROM tbl_MailDBX
WHERE (((tbl_MailDBX.ID)=1))
ORDER BY 3;
I still get 2 "cycles."
My point was that if I put a single quote
in front of Debug.Print and run the query
on all the 2829 records
SELECT tbl_MailDBX.ID, tbl_MailDBX.Topic,
fWordCount([FullLine]) AS WordCount
FROM tbl_MailDBX
ORDER BY tbl_MailDBX.Topic;
it opens immediately.
If I sort by calc field
SELECT tbl_MailDBX.ID, tbl_MailDBX.Topic,
fWordCount([FullLine]) AS WordCount
FROM tbl_MailDBX
ORDER BY fWordCount([FullLine]);
I did not have the patience to wait for
it to finish.
Likewise for
SELECT tbl_MailDBX.ID, tbl_MailDBX.Topic,
fWordCount([FullLine]) AS WordCount
FROM tbl_MailDBX
ORDER BY 3;
So.....I thought a "newbie" might want
to know that.
Peter, I don't recall saying anything
about sorting on the memo field,
but a "newbie" might want to know that
also.
Gary Walter