Quotes within a string variable

S

SAC

I'm not sure how to handle quotes within a string variable.

The variable is: "REV "D" DATED 03-07-00"

The quotes above are part of the literal varibale stored in a field in a
table.

How many quotes do I put around it so that it is evaluates with the quotes
within it.

I'm attempting to move this description to another table since this is in a
temporary table.

This is part of the code the SQL code:

strSQL = "TWDESC.DESC = " & rstmp!Desc & ";"

The problem is that rstmp!Desc has the quotes in it:

"REV "D" DATED 03-07-00"

Thanks for your help.
 
D

Dirk Goldgar

SAC said:
I'm not sure how to handle quotes within a string variable.

The variable is: "REV "D" DATED 03-07-00"

The quotes above are part of the literal varibale stored in a field
in a table.

How many quotes do I put around it so that it is evaluates with the
quotes within it.

I'm attempting to move this description to another table since this
is in a temporary table.

This is part of the code the SQL code:

strSQL = "TWDESC.DESC = " & rstmp!Desc & ";"

The problem is that rstmp!Desc has the quotes in it:

"REV "D" DATED 03-07-00"

Thanks for your help.

You need to get the string value enclosed in quotes, plus you need to
double-up each embedded quote in the string. Try this:

strSQL = "TWDESC.DESC = " & _
Chr(34) & _
Replace(rstmp!Desc, Chr(34), Chr(34) & Chr(34)) & _
& Chr(34) & _
";"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top