Hello,
I am getting the following error message "Syntax error (missing operator) in query expression". My search in google turned out that the cause of this error in my situation was an apostrophe being used. I have a bound data entry form with a field called Notes where the user can add as much as text as possible. However, it was brought to my attention that when they tried to write a comments with words that have an apostrophe (can't or let's) this error popped up.
I tried the below fix to allow text to be entered with an apostrophe, but then I am getting a "Error 94: Invalid use of Null".
Where the code for SafeSQL is:
I need this Notes field to be able to allow text to be added with apostrophes and allow it to be blank. How can I do this?
Thank you
I am getting the following error message "Syntax error (missing operator) in query expression". My search in google turned out that the cause of this error in my situation was an apostrophe being used. I have a bound data entry form with a field called Notes where the user can add as much as text as possible. However, it was brought to my attention that when they tried to write a comments with words that have an apostrophe (can't or let's) this error popped up.
I tried the below fix to allow text to be entered with an apostrophe, but then I am getting a "Error 94: Invalid use of Null".
Code:
CurrentDb.Execute "INSERT INTO QAMaster([EnteredBy], [DateEntered], [CycleMonth], [CycleYear], [ReportType], [DateReviewed], [ReviewerType], [Reviewer], [ReviewerReportArea], [MainSection], [TopicSection], [OwnershipIndividual], [OwnershipTeam], [Count], [Priority], [ApprovedBy], [L1], [L2], [L3], [Other], [RepeatAsk], [Exception], [Notes], [Outliers], [AdditionalOutlier], [Hyperlink], [PageNo])" & _
"VALUES ('" & Me.EnteredBy & "', '" & Me.DateEntered & "', '" & Me.CycleMonth & "', '" & Me.CycleYear & "', '" & Me.ReportType & "', '" & Me.DateReviewed & "', '" & Me.ReviewerType & "', '" & Me.Reviewer & "', '" & Me.ReviewerReportArea & "', '" & Me.MainSection & "', '" & Me.TopicSection & "', '" & Me.Individual & "', '" & Me.Team & "','" & Me.txtCount & "', '" & Me.PriorityLevel & "', '" & Me.Approved & "', '" & Me.L1 & "', '" & Me.L2 & "', '" & Me.L3 & "', '" & Me.txtOther & "', '" & Me.Repeat & "', '" & Me.Exception & "', [COLOR=#FF0000]'" & SafeSQL(Me.Notes) & "'[/COLOR], '" & Me.Outliers & "', '" & Me.txtOther2 & "', '" & Me.txtHyperlink & "', '" & Me.txtPageNo & "');", dbFailOnError
Where the code for SafeSQL is:
Code:
Public Function SafeSQL(strArg As String) As String
SafeSQL = Replace(strArg, "'", "''")
End Function
I need this Notes field to be able to allow text to be added with apostrophes and allow it to be blank. How can I do this?
Thank you