Combining VBA and SQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
We're trying to incorporate SQL code in VBA. Our attempts looks like this:

Sub test()
Dim results As Variant


results = "SELECT inventorytest.Product" & _
"FROM inventorytest" & _
"WHERE (((inventorytest.Product) Like " * a * "));"


End Sub

When we run this, we get a run-time error "13": type mismatch

Thanks in advance for your help,
Ellen
;-D
 
You need to change the double quote within the double quote into single
quote, and add space in the beginning of each line

results = "SELECT inventorytest.Product" & _
" FROM inventorytest" & _
" WHERE (((inventorytest.Product) Like '*a*'))"
 
EllenM said:
We're trying to incorporate SQL code in VBA. Our attempts looks like this:

And then what are you doing with the string? OpenRecordset?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top