Exporting fixed-width files without Carriage returns

  • Thread starter Thread starter Jove
  • Start date Start date
J

Jove

I would like to export a table in a fixed-width format but
without a Carriage returns at the end of each line. I
will be using the result in a program that does not want a
carriage return. How do you do this?
 
You can use a 3rd-party text editor to eliminate the carriage returns. I used UltraEdit-32 to insert carriage returns into streaming data source. It can be driven from the command line or VB. Hope it helps.

Greg
 
I'd do the same if this is a one-off task. If an an all-Access solution
is needed, you approach it along these lines:

-Use the old Open statement to create a new file for Random or Binary
access. If Random, set the record length to match what you need, e.g.
Dim lngFN as Long

lngFN = FreeFile()
Open "D:\folder\file.txt" For Random As #lngFN Len = 180

-Assemble the data for one record into a fixed-length string (the same
length as the record, obviously) and use Put to write it to the file:

Dim strLine As String * 180
Dim lngRecNo As Long
...
For lngRecNo = 1 to NumberOfRecords
'assemble record lngRecNo into strLine
Put #lngFN, lngRecNo, strLine
Next

Often the simplest way to assemble the record is to create a query that
returns a single calculated field containing the fixed width data.
 
Back
Top