I'm trying to take selected text from a text box and save the string to a table. There's only one row to the table, and the other variables (SelectionStart
, SelectionLength
) are able to save to the table without issue.
When it gets to the third RunSQL command, I get the error:
Run-Time error '3075': Syntax error (missing operator) in query expression
and ends with the selected text.
Sub ArticleTextContentBox_Click()
Dim SelectionStart As String
Dim SelectionLength As String
Dim SelectionText As String
SelectionStart = [Forms]![1CodingArticlesForm]![ArticleTextContentBox].SelStart + 1
SelectionLength = [Forms]![1CodingArticlesForm]![ArticleTextContentBox].SelLength
SelectionText = Mid([Forms]![1CodingArticlesForm]![ArticleTextContentBox], SelectionStart, SelectionLength)
'Runs successfully, to show that SelectionText variable works correctly
MsgBox SelectionText
DoCmd.RunSQL "UPDATE TEMP_StringPosition SET TEMP_StringPosition.StartLocation = " & SelectionStart & ";"
DoCmd.RunSQL "UPDATE TEMP_StringPosition SET TEMP_StringPosition.StringLength = " & SelectionLength & ";"
'This is the line that causes the error:
DoCmd.RunSQL "UPDATE TEMP_StringPosition SET TEMP_StringPosition.ExtractedTextChunk = " & SelectionText & ";"
End Sub
I'm not sure what I'm missing here as the first two variables are able to update the table without issue