I have the following in a form that runs from a button to append the information contained in unbound controls on the form.
MySQlLabRegHair = "INSERT INTO LabRegister ([CustomerId], [Lab], [Sample Date], [AHSCode], [Name]) " _
& "VALUES (" & Me![CustomerId] & ", '" & Me![Lab] & "', '" & Me![SampleDate] & "', " & Me![AHSCode] & ", '" & Me![CustomerName] & "') "
Which appends the selected information in the controls to the the table like its supposed too, EXCEPT in one situation.
When the name selected in the control [customerName] contains an apostraphy eg "O'Brien, John", I get the following error
Run time error 3075
Syntax Error (missing operator) in query expression "O'Brien'.
Any other name with hyphens or other characters are fine but every name with an apostraphy ' in it causes the code to fail.
The name field in the table is a string and the [customerName] control is a hidden one that gets its value from a drop down control which concatenates the name from firstname and lastname from the customer details table, which are all strings.
anyone have any ideas why this fails? cant figure out a reason why, when I go to debug after the error the Me![customerName] controls value is "O'Brien, John" just like it should be.
MySQlLabRegHair = "INSERT INTO LabRegister ([CustomerId], [Lab], [Sample Date], [AHSCode], [Name]) " _
& "VALUES (" & Me![CustomerId] & ", '" & Me![Lab] & "', '" & Me![SampleDate] & "', " & Me![AHSCode] & ", '" & Me![CustomerName] & "') "
Which appends the selected information in the controls to the the table like its supposed too, EXCEPT in one situation.
When the name selected in the control [customerName] contains an apostraphy eg "O'Brien, John", I get the following error
Run time error 3075
Syntax Error (missing operator) in query expression "O'Brien'.
Any other name with hyphens or other characters are fine but every name with an apostraphy ' in it causes the code to fail.
The name field in the table is a string and the [customerName] control is a hidden one that gets its value from a drop down control which concatenates the name from firstname and lastname from the customer details table, which are all strings.
anyone have any ideas why this fails? cant figure out a reason why, when I go to debug after the error the Me![customerName] controls value is "O'Brien, John" just like it should be.