
Originally Posted by
shurstgbr
I have a database where one of the fields contains the inch symbol ("). e.g. 02"-GP-1734-E17-N. However, I am trying to create an sql string in a module with a where clause based on the above field. The query sql is SELECT FINAL.ItemID, FINAL.*
FROM FINAL
WHERE (((FINAL.ItemID)="02""-GP-1734-E17-N"))
ORDER BY FINAL.ItemID;
but what do I have to do to make this work in a module as I am entering quotation mark hell!!!
Thanks in advance
I know this is hell. I have fought this battle several times...Have you tried assigning the value to a variable first?
Code:
strCriteria = "02""
SELECT FINAL.ItemID, FINAL.*
FROM FINAL
WHERE (((FINAL.ItemID)='" & strCriteria & "' & "-GP-1734-E17-N"))
ORDER BY FINAL.ItemID;
Would it be possible to replace the " with a ' ? I know you can replace a ' with '' (two single quotes) and SQL will treat that has a '.
Code:
strCriteria = "02""
strCriteria = Replace(strCriteria, "'", "''")
SELECT FINAL.ItemID, FINAL.*
FROM FINAL
WHERE (((FINAL.ItemID)='" & strCriteria & "' & "-GP-1734-E17-N"))
ORDER BY FINAL.ItemID;
Did you try surrounding the double-quote in double-quotes? (""").
Code:
strCriteria = "02""""
SELECT FINAL.ItemID, FINAL.*
FROM FINAL
WHERE (((FINAL.ItemID)='" & strCriteria & "' & "-GP-1734-E17-N"))
ORDER BY FINAL.ItemID;