User Profile

Collapse

Profile Sidebar

Collapse
kickbutt
kickbutt
Last Activity: Mar 14 '11, 03:35 PM
Joined: Mar 10 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • 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
    See more | Go to post

    Leave a comment:


  • 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 you
    See more | Go to post

    Leave 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
    ...
    See more | Go to post
    Last edited by Stewart Ross; Mar 11 '11, 12:17 AM. Reason: Code tags added
No activity results to display
Show More
Working...