Results 1 to 5 of 5
  1. #1
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49

    Question writing to textfile with string in " "

    Hey guys, I have a command where I write the record values to a text file. The code is working but I need to make small change.


    For example, this is my command:

    Code:
    Dim path As String
    path = Application.CurrentProject.path & "\export\"
    Open (path & "\export.txt") For Append As text
    Print #text, .Fields(1).Value & ";" & .Fields(2).Value & ";" & .Fields(3).Value & vbCrLf
    Close #text
    assume my field(1) value is a number, field2 value is text(string), field3 value is again a number..
    so my txt displays as:

    10;abcd;20


    However I need the string to be in quotes, like this:

    10;"abcd";20

    or

    10;'abcd';20


    Instead of 'Print' command, If I use the 'Write', then the whole line is displayed in quotes:

    "10;abcd;20"

    which I don't want to. Can someone help me with this?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try


    Print #text, .Fields(1).Value & ";'" & .Fields(2).Value & "';" & .Fields(3).Value & vbCrLf
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49
    It worked.
    Thank you.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem. You can get the double quotes with Chr(34) if you decide you want them instead.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49
    Oh..okay..thanks for the additional info..but I guess single quotes would suffice for my task...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 06-07-2013, 09:45 AM
  2. Replies: 8
    Last Post: 04-18-2013, 04:41 PM
  3. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  4. Writing Code for "After Update" Table Events
    By dipique in forum Programming
    Replies: 10
    Last Post: 07-09-2012, 08:11 AM
  5. Replies: 11
    Last Post: 03-29-2012, 02:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums