Hello!
I am attempting to take data from one table and insert it into another. I am encountering problems where data in a recordset may contain an apostrophe, which completely kills my SQL Insert.
Problem is, some of these records may also be Null, so that kills a Replace() call.
I've found a really sloppy way of getting around this, but it's horrendous!
Please help. Been trying to figure this out for over an hour, and each time I think I find a solution, some funky record comes up and knocks me down!
Thanks!
I am attempting to take data from one table and insert it into another. I am encountering problems where data in a recordset may contain an apostrophe, which completely kills my SQL Insert.
Code:
DB.Execute "INSERT INTO NEWTABLE (Record1) VALUES('" & rs![oldtext] & "')"
I've found a really sloppy way of getting around this, but it's horrendous!
Code:
oldvar = ""
if(Len(rs![oldtext]) > 0 then
oldvar = rs![oldtext]
oldvar = Replace(oldvar, "'", "''")
end if
DB.Execute "INSERT INTO NEWTABLE (Record1) VALUES('" & oldvar & "')"
Thanks!
Comment