I'm having problems passing values entered into a form to my Access backend. It works fine unless a single quote is entered into the form. i can't seem to get the sql string correct. any help would be aprreciated.
I've tried the following:
sql = "UPDATE tblEmployees SET"
sql = sql & " Name = '" & Name & "'"
sql = sql & " WHERE EmpNumber =" & empID
--returns Works without ' entered, otherwise Syntax error (missing operator) in query expression ''O'Brien' WHERE EmpNumber =1000'.
sql = "UPDATE tblEmployees SET"
sql = sql & " Name = " & chr(39) & Name & chr(39)
sql = sql & " WHERE EmpNumber =" & empID
--returns Syntax error (missing operator) in query expression ''O'Brien' WHERE EmpNumber =1000'.
sql = "UPDATE tblEmployees SET"
sql = sql & " Name = " & chr(34) & Name & chr(34)
sql = sql & " WHERE EmpNumber =" & empID
--returns Too few parameters. Expected 1.
sql = "UPDATE tblEmployees SET"
sql = sql & " Name = """ & FirstName & """"
sql = sql & " WHERE EmpNumber =" & empID
--returns Too few parameters. Expected 1.
Thanks,
Brian
I've tried the following:
sql = "UPDATE tblEmployees SET"
sql = sql & " Name = '" & Name & "'"
sql = sql & " WHERE EmpNumber =" & empID
--returns Works without ' entered, otherwise Syntax error (missing operator) in query expression ''O'Brien' WHERE EmpNumber =1000'.
sql = "UPDATE tblEmployees SET"
sql = sql & " Name = " & chr(39) & Name & chr(39)
sql = sql & " WHERE EmpNumber =" & empID
--returns Syntax error (missing operator) in query expression ''O'Brien' WHERE EmpNumber =1000'.
sql = "UPDATE tblEmployees SET"
sql = sql & " Name = " & chr(34) & Name & chr(34)
sql = sql & " WHERE EmpNumber =" & empID
--returns Too few parameters. Expected 1.
sql = "UPDATE tblEmployees SET"
sql = sql & " Name = """ & FirstName & """"
sql = sql & " WHERE EmpNumber =" & empID
--returns Too few parameters. Expected 1.
Thanks,
Brian