ironfelix717
Registered User.
- Local time
- Today, 14:51
- Joined
- Sep 20, 2019
- Messages
- 193
Unsurprised, yet again, that escaping quote characters in strings is profoundly difficult.
I am trying to escape the glorious apostrophe, aka chr(39).
Usage:
I've made several attempts after reading various threads. None have been successful, as the result is the unlikeable "Syntax error in query expression".
Many have said 'doubling up' the chr(39) is the way to escape.
False. Does not work. At least with JET/ACE.
Whats the trick?
Thanks in advance.
I am trying to escape the glorious apostrophe, aka chr(39).
Usage:
Code:
Sub test()
Dim Criteria As String
Dim SQL As String
Criteria = "Mc'Hammer"
SQL = "SELECT * FROM POINVrec_Line WHERE MaterialID = '" & Criteria & "';"
Debug.Print SQL
DoCmd.RunSQL SQL 'FAIL......
End Sub
I've made several attempts after reading various threads. None have been successful, as the result is the unlikeable "Syntax error in query expression".
Many have said 'doubling up' the chr(39) is the way to escape.
Code:
If InStr(1, Criteria, Chr(39)) > 0 Then
Criteria = Replace(Criteria, Chr(39), Chr(39) & Chr(39))
End If
Whats the trick?
Thanks in advance.