darkmunk
-
Total Posts
:
4
- Scores: 0
-
Reward points
:
0
- Joined: 1/16/2007
-
Status: offline
|
using recordset in 'LIKE' query (sql)
Tuesday, January 16, 2007 5:02 AM
( permalink)
trying to search a DB for all records within a range. I have a recordset containing about 10 postcodes and I need to find all the records in a different Table containing any one of those postcodes currently I have: Code: sqlString= "SELECT aucTitle FROM tblAPAuctions WHERE aucPostalCode LIKE '%" & left(rsPostcodeResult.Fields, 4) & "%'" but I am getting 'Wrong number of arguments or invalid property assignment ' error. Thanks for looking Mark
<message edited by darkmunk on Tuesday, January 16, 2007 7:41 AM>
|
|
|
|
darkmunk
-
Total Posts
:
4
- Scores: 0
-
Reward points
:
0
- Joined: 1/16/2007
-
Status: offline
|
RE: using recordset in 'LIKE' query (sql)
Tuesday, January 16, 2007 10:22 PM
( permalink)
this code will loop thru a recordset and use each postcode in a new 'Like' query
rsPostcodeResult.moveFirst
' Fetch the first postcode to avoid an OR to many!
sqlString= "SELECT aucTitle FROM tblAPAuctions WHERE aucPostalCode LIKE '%" & rsPostcodeResult("postcode") & "%'"
' Move the set-pointer one row down and go into the loop
rsPostcodeResult.moveNext
Do while not rsPostcodeResult.eof
sqlString=sqlString & " OR aucPostalCode LIKE '%" & rsPostcodeResult("postcode") & "%'"
rsPostcodeResult.moveNext
Loop
|
|
|
|