Hi All
I am building an insert query from fields on a form and everything was working ok until a user added an apostrophe in a free text field which caused the query to not build correctly. So something like this:
So in the text field the user had entered: "This can't be done"
And this caused the query to fail. So my question is, is there a good way to santise the data in such circumstances or a way to cope with it where if the user enters nothing it still works as well. I tried with double quotes instead of single quotes but then when the freeTextField was empty things didn't work either.
Hope that all makes sense.
Kind regards
Glen
I am building an insert query from fields on a form and everything was working ok until a user added an apostrophe in a free text field which caused the query to not build correctly. So something like this:
Code:
db.Execute "INSERT INTO [TABLE] (freeTextField) VALUES ('" & Me.freeTextField & "')", dbFailOnError
So in the text field the user had entered: "This can't be done"
And this caused the query to fail. So my question is, is there a good way to santise the data in such circumstances or a way to cope with it where if the user enters nothing it still works as well. I tried with double quotes instead of single quotes but then when the freeTextField was empty things didn't work either.
Hope that all makes sense.
Kind regards
Glen