Exporting fixed-width files without Carriage returns

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?
 
D

db_slave

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
 
J

John Nurick

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top