hi Mike
I have tried both of your suggestions and the macro is working exactly as it was...
It still displays -1 as the recordcount and does not match the StockCode with StringVal.
I don't think the data is looping as StringVal always returns nothing
thank you
User Profile
Collapse
-
thanks for that Mike!
another line that will need addressing is where i have:
If StringVal = StockCode then
Switch = True
End If
this just does not work, everytime i run the macro it says the stockcode is invalid even though it exists in the table.
thank youLeave a comment:
-
How to use excel VBA to SQL query and compare data?
I have the below code, which queries a database and compares the recordset against my variable 'StockCode'.
This is not currently working and if i add the line 'Msgbox rs.recordcount' then this comes back with the message '-1'.
However, when i add the line 'ActiveSheet.Ra nge("A5").CopyF romRecordset (rs)' then all records are pasted in to my excel spreadsheet. can someone see what i am doing wrong?
...Code:Sub
No activity results to display
Show More
Leave a comment: