View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Variable names in SQL

Try something like the following:

sqlstring = "select * from mytable where mycolumn='" & testvalue
& "'"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Hall" wrote in message
...
My VBA code has an SQL statement to call. I'm assigning the

statement to a
string variable and use this variable to call it later. The

statement has a
condition (the "where" clause) that needs to compare a column

name to
another variable's value.

What is the syntax for this? For example:

testvalue="boo"
sqlstring="select * from mytable where mycolumn=testvalue"

How do I mark testvalue in the select string?