• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel to Access VBA - Syntax Error, Data not returned - help

Ramm_66

New Member
Code:
  SQL = "SELECT * FROM " & strTable & " WHERE Area = '" & Sheets("Sheet1").Range("A1") & "' AND Place =" & Sheets("Sheet1").Range("A2") & ""

Dear Gurus

Please help on the above error, I have attached my file as well.

I am trying to get data from a table in access database. All my parameters are in excel VBA and excel cells.

In the above code when I type exact matching parameter thequery works but when I put "*" to select all from a column it is not returning any values. Can you please help me on this.

So that If I can give parameter to Area like "IT " and parameter for place will be '*' to select Area as IT and places includes All.

Many thanks for your help in Advance.
 

Attachments

  • Working Testing 23102015.xlsm
    24.6 KB · Views: 0
Last edited:
I just figured the answer. Thanks a lot Gurus. Code changed as below

Code:
SQL = "SELECT * FROM " & strTable & " WHERE Area = '" & Sheets("Sheet1").Range("A1") & "' AND Place Like '" & Sheets("Sheet1").Range("A2") & "'"
 
Back
Top