Reputation: 81
I am using excel sql queries to fetch data from the backend according to the selection i make in a dropdown box.However my sql queries are not working in cases where there is a single quote(') in the dropdown box value. For example-- Men's Wear . Please suggest me a way to deal with this problem
SQL = "select Segment,Weeks,Value from [Category performance data$] where Departments='" & Sheet3.Range("Dept_name").Value & _
"' and Metric ='Total Spend' group by Segment,Weeks,Value"
Call execQry
Upvotes: 1
Views: 1957
Reputation: 238296
Departments='" & replace(Sheet3.Range("Dept_name").Value, "'", "''") & _ "' and Metric
Upvotes: 2