adraughn
asked on
Apostrophe included in SQL Insert string
I'm sure someone has the perfect answer for this. what is the trick to inserting text into a table via sql/vba that includes apostrophe's? (Or other characters that will break it for that matter?)
For instance, I am using this code:
For instance, I am using this code:
For j = 0 To 1
'Save Row and Column Descriptions
If j = 0 Then c = "Row" Else c = "Col"
strSQL = "INSERT INTO tbHRI_Descrip (HRI_ID,Descrip_ID,DescripType,Label," & _
"Description)" & _
"VALUES ('" & Me.txtHRI_ID.Value & "','" & i & "','" & c & "','" & _
Me.Controls("txt" & c & "Label" & i).Value & "','" & _
Me.Controls("txt" & c & "Descrip" & i).Value & "')"
DoCmd.RunSQL strSQL
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
chr(34) is double quote { " }
it will store the value as string's ., ex. O'Brien
it will store the value as string's ., ex. O'Brien
>so in angel's solution, the table will show an apostrophe as a double apostrophe?
no. duplicating the single quote into 2 single quotes is ONLY for the insert to work.
after the insert, there will indeed only be 1 single quote in the table.
no. duplicating the single quote into 2 single quotes is ONLY for the insert to work.
after the insert, there will indeed only be 1 single quote in the table.
ASKER
in cap's solution, is chr(34) an apostrophe? So would it store the string in the table as 'string's' instead of string's?