Using ""

davesmith202

Employee of Access World
Local time
Today, 19:55
Joined
Jul 20, 2001
Messages
522
I want to create a string that looks like this:

Data,"Data",[Data]

Currently, I am using "Data," & "'" & "Data" & "'" & ",[Data]"

But this gives...

Data,'Data',[Data]

Any solution to this?
 
"Data," & "" & "Data" & "" & ",[Data]"

???
 
Nope, that doesn't do it. Perhaps it is impossible to have a " inside a string!
 
"Data,""" & "Data" & """,[Data]"

???
 
Well, my actual string is:

Code:
txtKeywords = "[" & strSubProduct & "]" & Chr(13) & Chr(10) & "'" & strSubProduct & "'" & Chr(13) & Chr(10) & strSubProduct

So that wouldn't be possible would it?
 
txtKeywords = "[" & strSubProduct & "],""" & strSubProduct & """" & strSubProduct

???
 
To have " inside a string you need to double it up within the string's delimiters.

i.e.

Code:
MsgBox "There's a "" in this message."
 
This requires more typing than SJ McAbney's but the Chr() function allows you to use special symbols in strings, etc.
Code:
MsgBox "There's a " & Chr(34) & " in this message."
 
I have a follow on problem with this now. I have managed to store the " in the field. But When I try to build up a string with them in it, I have problems!

Code:
        strkeywordlist = Replace(![Keywords], vbCrLf, ",")
        MsgBox strkeywordlist
        'strKeywordList = ![Keywords]
        strAdwordsCSV = strAdwordsCSV & ![Campaign] & "," & ![MaxCPC] & "," & ![Adgroup] & "," & ![Title] & "," & ![Line1] & "," & ![Line2] & "," & ![DisplayURL] & "," & ![ActualURL] & "," & strkeywordlist & Chr(10)

What I have found is that strAdwordsCSV ends up with the Keywords in the string but with the " stripped out. Any way around that?

A typical Keywords field (memo type) would have the following:

[graduate jobs]
"graduate jobs"
graudate jobs

Any ideas on how to get this into the strAdwordsCSV string but without losing the quotes on the second row?
 
You're doing that thing with that horrible ! again.

Based on the post above, I can't see what the problem is.
 
If you have the value stored with the inverted commas, your code would have to work. Maybe you lose it when taking the values from the field. Please make a little check:

Code:
Dim strtmp(3) as string
strtmp(0) = "DATA"
strtmp(1) = """DATA"""
strtmp(2) = "[DATA]"
strtmp(3) = strtmp(0) & "," & strtmp(1) & "," & strtmp(2)
MsgBox strtmp(3)

That should return DATA,"DATA",[DATA]
After that, check replacing the strtmp(1) value ("""DATA""") with your control value. If the result is not the same... try replacing your control name for:
Format(ME.[YOURCONTROL],"@")
...to be sure the value stored is taken as a string
If it doesn't work... please, more info!
 
in the csv quotes need to be double quoted as well :)
try
strkeywordlist = Replace(![Keywords], vbCrLf, ",")
strkeywordlist = Replace(strkeywordlist, Chr(34), Chr(34) & Chr(34))

HTH

Peter
 

Users who are viewing this thread

Back
Top Bottom