Building String for Printing to Delimited Text File

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello!

I need to append records to a comma and quote delimited text file, such as:

"Field_1",123,"Field_2","Field_3"," ","Field_4", etc.

I am trying to build a text string within Access and use the Print command to
write the string to the text file. But I can't figure out the proper syntax to
embed the quote delimiters. (Note that Field_1, Field_2, etc. need to reflect
the values of those fields -- not the field names treated as literals.)

Note also that I cannot use the Access export utility because this apparently
does not allow updating of a text file in append mode!

Please help!

Tom
 
Tom said:
I need to append records to a comma and quote delimited text file, such as:

"Field_1",123,"Field_2","Field_3"," ","Field_4", etc.

I am trying to build a text string within Access and use the Print command to
write the string to the text file. But I can't figure out the proper syntax to
embed the quote delimiters. (Note that Field_1, Field_2, etc. need to reflect
the values of those fields -- not the field names treated as literals.)

You can use any of the following to produce a " in the
output:
"""" four double quotes
'"' single quote, double quote, single quote
Chr(34) the ascii code for a quote

Your Print statement could then look something like:

Print Chr(34);field1;Chr(34);",123,";Chr(34);field2; _
Chr(34);",";Chr(34);field3;Chr(34);","" "","; _
Chr(34);",";Chr(34);field4;Chr(34)

It might be easier to test it using Debug.Print instead of
printing to a file.
 
Back
Top