I’m using excel to input data into an Access database and some of my data strings contain an apostrophe for measurements.
This is my SQL input string
stSQL = "INSERT INTO Products (ProductName, ProductDescription, ProductUnit, SupplierID) " & _
"Values ('" & cboxItemNum & "', '" & txtDescription & "', '" & txtUnit & "', " & linkPID & ")"
cn.Execute (stSQL)
My string is as follows:
Aliplast 4E White. 30″ X 80′ X 1/4″ Soft.
In this string the ‘ after the 80 is causing the error and I’m not sure how to get around this. I can’t just tell the user not to enter an apostrophe. How can I get around this?
Thanks
You can correct this either by using parameters (recommended) or by using Replace.
Parameters
Note that while I have named these parameters param1 to param4, that is for my convenience, all that matters is the order, which must match the order in which the parameters are to be used.