Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding line feed to text file 1

Status
Not open for further replies.

seqpet

Technical User
Feb 27, 2001
2
US
I'm trying to export an Access 97 table to a text file and add a line feed at the end of each record so that the table can be imported using Ingres software. The file needs to be pipe (|) delimited. I tried using the TransferText action / Export Delimited with a spec that set the field delimiters. I guess Access must add a carriage return but I haven't been able to add a line feed. I tried appending Asci character 10 at the end of the last field in each record but that did not help. The user importing the file says that she sees "\R \R" at the end of the record but she needs to see "\R \N". Any suggestions?
 
Don't know about Ingress. MS Access generally does an O.K. job of exporting. If the LF is the only problem, I only know one way to do it.

Export the file as you currently do. Add a section to read/repalce the cr with crlf.

The code would look approximatly like:
Code:
Public Function basRepCr_w_CrLf(InFile As String, OutFile As String)

    Dim MyInFil As Integer
    Dim MyOutFil As Integer
    Dim MyLine As String


    MyInFil = FreeFile
    Open InFile For Input As MyInFil

    MyOutFile = FreeFile
    Open OutFile For Input As #MyOutFile

    While Not EOF(MyInFil)
        Line Input #MyInFil, MyLine
        MyLine = Left(MyLine, Len(MyLine) - 1) & vbCrLf
        Print #MyOutFile, MyLine
    Wend

    Close #MyInFil
    Close #MyOutFil

End Function

Of course, this has no error checking, and is entirely untested. To try it, just make sure the full path name is provided for both InFil and outFil. Also, make sure the names are NOT the same.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
FYI,

If you tried appending character 10 at the end you only did part of the job. What you need to get a line feed is really a carriage return/line feed:

Chr(10) & chr(13) (For Access 2.0 and below)
OR
vbCrLf (For > Access 2.0)

Steve King
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top