strSQL2 = "SELECT [" & strTbl & "].[" & strFld & "] FROM [" & strTbl & "]
WHERE " & _
"[" & strFld & "] Like '%' & '" & Chr(39) & "' & '%'"
I am not quite sure what this Chr() bit is doing. I think the final command
should look something like this:
SELECT Eggs FROM Breakfast WHERE Eggs LIKE '%["]%'
Note that you don't need to keep referencing the table name since there is
only one table involved. And assuming that you have normal legal names, the
braces only serve to obfuscate too. Actually, since the double quote is not
special in T-SQL, you can dispense with those braces too:
SELECT Eggs FROM Chickens WHERE Eggs LIKE '%"%'
So, to get this from a VBA statement, you need something like
strSQL = "SELECT " & strFld & " FROM " & strTbl & _
" WHERE " & strFld & " LIKE '%""%'"
MsgBox strSQL
... and please don't forget the second line!!
If you are looking for a single character, then using CHARINDEX makes the
thing much easier to read and might be quicker:
SELECT Eggs FROM Chickens
WHERE CHARINDEX(N'"', Eggs)>0
or
strSQL = "SELECT " & strFld & " FROM " & strTbl & _
" WHERE CHARINDEX(N'""', " & strFld & ") > 0"
MsgBox strSQL
Hope that helps
Tim F