Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Wirral, Merseyside, Merseyside, England
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Export to Text file and add text to file (Access 97)

    Does anyone know how to export a table to a text file and then append a line at the top of the text file?

    Doing the export to a text file is no problem its just how to manipulate the text file to add a row at the top.

  2. #2
    New Lounger
    Join Date
    Nov 2002
    Location
    Jubail, Eastern Province
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Export to Text file and add text to file (Acce

    What do you want in the line.? Are you doing this automatically?

  3. #3
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Export to Text file and add text to file (Access 97)

    How are you currently doing the export? Manually or through code?

    That may have an impact on the solutions you get.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  4. #4
    Star Lounger
    Join Date
    Feb 2001
    Location
    Wirral, Merseyside, Merseyside, England
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Export to Text file and add text to file (Access 97)

    We want to be able to do this automatically in code running from a button on a form.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Export to Text file and add text to file (Access 97)

    One possibility is a procedure like this:

    Sub AddLineToTextFile(sInFile As String, sOutFile As String, sExtraLine As String)
    Dim strLine As String
    Open sInFile For Input As #1
    Open sOutFile For Output As #2
    Print #2, sExtraLine
    Do While Not EOF(1)
    Line Input #1, strLine
    Print #2, strLine
    Loop
    Close #2
    Close #1
    End Sub

    Call it as follows:

    AddLineToTextFile "C:ExportFromAccess.txt", "C:ExportWithAddedLine.txt", "This is a test of the emergency broadcasting system."

  6. #6
    Star Lounger
    Join Date
    Feb 2001
    Location
    Wirral, Merseyside, Merseyside, England
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Export to Text file and add text to file (Access 97)

    Just the thing

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •