Table Filter variable with apostrophe

JamesC

Member
Licensed User
How do I TableFilter using a variable if the variable contains an apostrophe?

e.g. x="l'ami"

table1.filter("Name = '" & x & "'") will throw up an error, while it will work for variables that don't contain an apostrophe.

Thanks

James
 

JamesC

Member
Licensed User
Ta

Thanks Erel, that's what I thought. I'll rewrite my filter code to check for apostrophes.

What do you think - perhaps it would be a good idea to have a filter command that just dealt with variables, as I imagine this is how it is often used? At present, using different syntax for numbers and strings makes it a little more complex - but perhaps that is just my application, which has a one button filter of the selected column by the contents of the selected cell. I need different syntax depending on whether the column holds numbers or strings. Which is not too difficult. But then adding code to look for apostrophes!!!

Best regards!
 

BPak

Active Member
Licensed User
Longtime User
You could try substituting the ' with an underline _
in the string and then do the LIKE 'sqlite_'

In the SQL i Use in C I can use either the Underline or the % as a substitue for any char in the LIKE String. SQLite should be able to use this.
 

digitaldon37

Active Member
Licensed User
Longtime User
Would using double quotes for the query instead of single quotes work?

table1.filter("Name = " & chr(34) & x & chr(34) & "")
 
Top