using recordset in 'LIKE' query (sql)

Author Message
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)
0
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>
 
#1
    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)
    0
    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

     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9