G
Guest
I have the following code in a form:
Private Sub insert_filenames(file_name As String)
Dim sqlstring As String
sqlstring = "insert into filenames " _
& "(filename) " _
& " values ('" & file_name & "')"
DoCmd.RunSQL sqlstring
End Sub
Everything is fine until the file_name variable contains a single quote (').
I've tried chr(34) and everything else I can read about but when file_name
contains a single quote, it gives me an sql error.
How can I format the code above to insert values containing a single quote?
Thanks in advance for your help!
Private Sub insert_filenames(file_name As String)
Dim sqlstring As String
sqlstring = "insert into filenames " _
& "(filename) " _
& " values ('" & file_name & "')"
DoCmd.RunSQL sqlstring
End Sub
Everything is fine until the file_name variable contains a single quote (').
I've tried chr(34) and everything else I can read about but when file_name
contains a single quote, it gives me an sql error.
How can I format the code above to insert values containing a single quote?
Thanks in advance for your help!