B
bacadman
Hello All,
I am new to vba am and encountering some issues when attempting to run a sql
statement. I am having issues with Single Quotes and Double quotes causing
errors. If the values contain any single or double quotes I get an error.
See code below.
strSQL = "insert into newDB values ('" _
& rs.Fields(0).Value & "', '" &
rs.Fields(1).Value _
& "', '" & rs.Fields(2).Value & "', '" &
rs.Fields(3).Value _
& "', '" & rs.Fields(4).Value & "', '" &
rs.Fields(5).Value _
& "', '" & rs.Fields(6).Value & "', '" &
rs.Fields(7).Value _
& "', '" & rs.Fields(8).Value & "', '" &
rs.Fields(9).Value _
& "', '" & rs.Fields(10).Value & "', '" &
rs.Fields(11).Value _
& "', '" & rs.Fields(12).Value & "', '" &
rs.Fields(13).Value _
& "', '" & rs.Fields(14).Value & "' )" '
DoCmd.RunSQL strSQL
Any assistence is appreciated.
Thanks in advance.
I am new to vba am and encountering some issues when attempting to run a sql
statement. I am having issues with Single Quotes and Double quotes causing
errors. If the values contain any single or double quotes I get an error.
See code below.
strSQL = "insert into newDB values ('" _
& rs.Fields(0).Value & "', '" &
rs.Fields(1).Value _
& "', '" & rs.Fields(2).Value & "', '" &
rs.Fields(3).Value _
& "', '" & rs.Fields(4).Value & "', '" &
rs.Fields(5).Value _
& "', '" & rs.Fields(6).Value & "', '" &
rs.Fields(7).Value _
& "', '" & rs.Fields(8).Value & "', '" &
rs.Fields(9).Value _
& "', '" & rs.Fields(10).Value & "', '" &
rs.Fields(11).Value _
& "', '" & rs.Fields(12).Value & "', '" &
rs.Fields(13).Value _
& "', '" & rs.Fields(14).Value & "' )" '
DoCmd.RunSQL strSQL
Any assistence is appreciated.
Thanks in advance.