Count Input Box Word (1 Viewer)

Haitham

Registered User.
Local time
Today, 08:40
Joined
Oct 27, 2002
Messages
17
Dear There,

I have a table with memo field wich contain hug duplicate text,
i need code to search the word that i specify in inputbox in each and every that memo field and goto next record and count it also.

Thanx in Advance
 

Travis

Registered User.
Local time
Yesterday, 22:40
Joined
Dec 17, 1999
Messages
1,332
Code:
Public Function NumInstances() as Long
   Dim rst as ADODB.RecordSet
   Dim arData as Variant

      stSplit=InputBox("Enter the Search String")

      Set rst = New ADODB.RecordSet
      rst.Open "Select * from [tblName]",CurrentProject.Connection,,adOpenStatic,adLockReadOnly 
      If rst.RecordCount>0 then
         rst.MoveFirst
         Do While Not rst.EOF         
             arData=Split(rst.Fields("MEMOFIELDNAME"),stSplit)
             lCount=lCount+ubound(arData)
             rst.MoveNext
         Loop

      End If
      MsgBox "Number of Instances of " & stSplit & ": " & lCount
      NumInstances=lCount

End Function
 

Haitham

Registered User.
Local time
Today, 08:40
Joined
Oct 27, 2002
Messages
17
Thank You

Dear Travis,

The Resault Gives Me The MsgBox With Out The Number Of Count Just " Number Of Instances Of MyWord:"

Thanks In Advance
Haitham
 

Haitham

Registered User.
Local time
Today, 08:40
Joined
Oct 27, 2002
Messages
17
I Just Modefy And Working Like Charmy,

Thank You,

Public Function NumInstances() As Long

Dim arData As Variant

stSplit = InputBox("Enter the Search String")
Set rs = CurrentDb.OpenRecordset("Select * from [Sheet2]")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
arData = Split(rs.Fields("Aaya"), stSplit)
lCount = lCount + UBound(arData)
rs.MoveNext
Loop

End If
MsgBox "Number of Instances of " & stSplit & ": " & lCount
NumInstances = lCount

End Function

Thank you alot
Haitham
 

Haitham

Registered User.
Local time
Today, 08:40
Joined
Oct 27, 2002
Messages
17
More Problem

Dear Travis,

But That Is Counting For The Like InputBox Not =, What about if i want to count for exact full word

Thanks
 

Travis

Registered User.
Local time
Yesterday, 22:40
Joined
Dec 17, 1999
Messages
1,332
Add a Space to your text at the end.
 

Users who are viewing this thread

Top Bottom