sorry about that...ok, here is the scenario:
I have a list of 2 character values (example: I0,7U,99,a',##,H&,/",Mm)
This is stored in a table called "2List"....I have created code to
automatically take each value within that list and place it into another
table "finallist". The values in "finallist" have multi records, now the code
takes those records and places the values in "2List" that are supposed to
match (example: 1111-IO, 1111-H&). **the last two characters make the
finished value**
As you can see in the "2List" examples above there is a value = /"
when the code to write to "finallist" runs, it comes back with a syntax
error because it sees the " (quotation) in that value as another "
(quotation) in: ....VALUES(""" & txtVal & """)....
txVal = the values in "2List", the code runs through each record until end
of file.
I hope I have explained my problem better...thanks for your help!!!
:
*** snipped ***
In other words, sometimes you'll have a " in the string and sometimes
a ' and other times neither?
Here is how I handle these situations. Test for the apostrophe.
This will work whether there is an ', ", or neither in the string
If InStr(strValue, "'") = 0 Then ' No apostrophe
strSQL = "Insert Into [ImportData2] (ccNumber) Values ('" & strValue &
"');"
Else
' there is an apostrophe
strSQL = "Insert Into [ImportData2] (ccNumber) Values (""" & strValue
& """);"
End If
CurrentDb.Execute strSQL, dbFailOnError
Change strValue to whatever your variable name is, and of course use
your own Insert Into Table and Fielhd names.