Hi,
what I want to do is to run a query like this one:
Code:
SELECT RadID,Leverantor FROM InkopsOrder WHERE Leverantor LIKE '%kompaniet%'
which works fine, but I want the '%kompaniet%' part to be a parameter, like this:
Code:
"SELECT RadID,Leverantor FROM InkopsOrder WHERE Leverantor LIKE ?"
And I can't get it to work out! The problem is I don't get anything in my recordset when using the second query.
Here's what my code looks like:

Code:
Set comm.ActiveConnection = conn
comm.CommandText = _
    "SELECT RadID,Leverantor FROM InkopsOrder WHERE Leverantor LIKE ?"
sokstrang = "'%" & InputBox("Söksträng?") & "%'"
comm.Parameters(0) = sokstrang
rec.Open comm
ws.[a1].CopyFromRecordset rec
'ws.[d1].Cells(1) = comm.Parameters(0)
The
'ws.[d1].Cells(1) = comm.Parameters(0)
is there so I can check that the parameter actually has the value '%kompaniet%', which it has.

Now, i cant use
Code:
"SELECT RadID,Leverantor FROM InkopsOrder WHERE Leverantor LIKE '%?%'"
Or anything like that since It doesnt seem to recognize ? as a parameter when I do.

PLEASE help me out on this one :P
thanks.
Reply With Quote