I have an SQL (string) variable named: strSQL.
I am trying to use an inputbox (or even a textbox) to manually alter the SQL code and change the QueryDef.
So (let's just say for the "Where Clause") I have something like:
strSQL = inputBox("Enter Where Clause")
The issue is, the InputBox double-quotes get doubled up.
For Example:
If I enter (into my InputBox):
Where [Table1].[Field1] Like "*000*"
Access changes my strSQL variable to post with an extra set of double quotes:
Where [Table1].[Field1] Like ""*000*""
---------------------------------------------------------------------------------------
If I enter (into my InputBox) no quotes:
Where [Table1].[Field1] Like *000*
my strSQL variable will post without quotes:
Where [Table1].[Field1] Like *000*
---------------------------------------------------------------------------------------
If I enter single quotes (into my InputBox):
Where [Table1].[Field1] Like '*000*'
Access changes the single quotes to double quotes, and adds an extra set of double quotes:
Where [Table1].[Field1] Like ""*000*""
---------------------------------------------------------------------------------------
I've tried using the Replace() function some examples:
Replace(strSQL, """", """)
Replace(strSQL, """", "& chr(34) &")
Replace(strSQL, "" & chr(34) & chr(34) & "", "& chr(34) &")
none of these work!
---------------------------------------------------------------------------------------
So I want to run through strSQL (after the fact) and create a function that parses through the entire string to remove the double-double quotes (i.e. "") and change them to one double quote (i.e. ")
But I don't know how to search for a literal double quote (") within a string, let alone two ("") side by side within the string...
for example, these won't work:
Instr(strSQL, """)
Instr(strSQL, "" & chr(34) & "")
Instr(strSQL, " & chr(34) & ")
Very Respectfully,
Gary
I am trying to use an inputbox (or even a textbox) to manually alter the SQL code and change the QueryDef.
So (let's just say for the "Where Clause") I have something like:
strSQL = inputBox("Enter Where Clause")
The issue is, the InputBox double-quotes get doubled up.
For Example:
If I enter (into my InputBox):
Where [Table1].[Field1] Like "*000*"
Access changes my strSQL variable to post with an extra set of double quotes:
Where [Table1].[Field1] Like ""*000*""
---------------------------------------------------------------------------------------
If I enter (into my InputBox) no quotes:
Where [Table1].[Field1] Like *000*
my strSQL variable will post without quotes:
Where [Table1].[Field1] Like *000*
---------------------------------------------------------------------------------------
If I enter single quotes (into my InputBox):
Where [Table1].[Field1] Like '*000*'
Access changes the single quotes to double quotes, and adds an extra set of double quotes:
Where [Table1].[Field1] Like ""*000*""
---------------------------------------------------------------------------------------
I've tried using the Replace() function some examples:
Replace(strSQL, """", """)
Replace(strSQL, """", "& chr(34) &")
Replace(strSQL, "" & chr(34) & chr(34) & "", "& chr(34) &")
none of these work!
---------------------------------------------------------------------------------------
So I want to run through strSQL (after the fact) and create a function that parses through the entire string to remove the double-double quotes (i.e. "") and change them to one double quote (i.e. ")
But I don't know how to search for a literal double quote (") within a string, let alone two ("") side by side within the string...
for example, these won't work:
Instr(strSQL, """)
Instr(strSQL, "" & chr(34) & "")
Instr(strSQL, " & chr(34) & ")
Very Respectfully,
Gary