PUG
PUG

Reputation: 4472

Find a part of field using ADODB.Recordset in vb6

I have a table in mdb with field address, which will contain street address e.t.c as string. I want to be able to search part of this record.

 sCriteria = "address like " & "'" & streetAddr & "'"

   Rs1.Filter = sCriteria

it searches for e.g "Mall" while there is a record "Mall Road" which should have been found but is not as Road is missing, what should i do to make part of field searchable

Upvotes: 0

Views: 6449

Answers (2)

wqw
wqw

Reputation: 11991

Try

sCriteria = "address like '*" & Quote(streetAddr) & "*'"

where Quote does a simple Replace(sText, "'", "''")

Upvotes: 3

Eight-Bit Guru
Eight-Bit Guru

Reputation: 10001

Put an '*' before the closing single-quote, after the filter value.

Upvotes: 0

Related Questions