Hi. Sorry in advance as I am sure this has been answered before but I just cant find it anywhere. It is a question about formatting a query string in VBA to correctly handle comma separated values.
I have a field I need to update in a table in a 3rd party application (I did not design it). The value I need to insert is a string containing comma separated values.
For example:
30s Playtime 2017 Scarlet Dotty Daisy 33214-21, 30s Playtime 2017, 30s Playtime 2017 fabric, Moda 30s Playtime 2017, Chloe's Closet 30s Playtime 2017,
Just to be clear this is a single value of a field. It is meta data to be added to a page on a website.
I create the contents of the field called Me.ProductMeta in VBA and want to run a query to update the value in the product table:
Code:
strUpdate = "UPDATE Product" & vbCrLf & _
"SET " Product.sSPPMetaKeyWords = " & Chr$(39) & Me.ProductMeta & Chr$(39) & "," & vbCrLf & __
" WHERE Product.[Product Reference] = " & Chr$(39) & ProductRefAsString & Chr$(39) & ";"
db.Execute strUpdate, dbFailOnError
Access is complaining as it is seeing the commas in my string Me.ProductMeta as field separators rather than data to be inserted into the field.
Please could someone tell me how I get Access to see them correctly in the update query?
Many thanks
Tony