I'm trying to determine if the data in a string field is found in a list of possible strings. It needs to be an exact match. I can use a bunch of 'If' statements obviously, but is there a better way to search for a match, and then keep a record of matches, or non-matches? I don't want to generate any errors if no matches are found, just keep a counter.
Thanks.

I found this, but is there a better way?

CheckNullData = IsNull(Recordset.Fields("DataToLocate"))
Dim FindData As String
If CheckNullData Then
FindData = "No Data"
Else
FindData = Recordset.Fields("DataToLocate")
End If
Dim StringPos As Integer
StringPos = 0
StringPos = InStr(1, DataListToSearch, FindData, vbTextCompare)
If StringPos = 0 Then
dblNotFounds = dblNotFounds + 1
End If

Hi
try the Following code

dim count() as integer
dim SearchStr,TempStr,SourceString as string
rs.movefirst
For i=0 to rs.recordcount-1
redim count(i+1) preserve
count(i)=0
TempStr=sourceString
SearchStr=rs.fields("SearchString")
while Tempstr<>""
if instr(1,Tempstr,searchstr,vbTextCompare)>0 then
RefIndex=(1,Tempstr,searchstr,vbTextCompare)
tempStr=mid(tempstr,refindex+len(searchStr)

count(i)=count(i)+1
else
tempstr=""
end if
wend
rs.movenext
next

for i=0 to rs.recordcount-1
msgbox Count(i)
next


With Regards
Venkatramasamy SN

hi
in the previous post the preserve keyword used in wrong place,right syntax is
redim preserve count(i+1)

With Regards
Venkatramasamy SN

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.