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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dilemma Creating and Exporting Text File

Status
Not open for further replies.

Bonediggler1

Technical User
Jul 2, 2008
156
0
0
US
Hello -

I have a bit of a dilemma here.

I have to generate a fixed-width text file that follows this pattern:

Header Record
Invoice Header Record
Line Records
Trailer Record

Now the problem is that the fields in the different records are obviously not the same, and the spacing between fields in different records is not the same. In order to generate the file I am using loops in VBA to craft the records and then insert them into a single field in a table.

Everything works perfectly - except when it comes to exporting. As I need to put all data into only one field in the table, the field can obviously only have one length specified in the export spec, regardless of record type. However, the different record types need to have different overall lengths...i.e. the Header Record needs a carriage return at 200, the Invoice Header needs a carriage return at 350, etc.

This is due to customer requiremenst for importing the file.

Not sure what to do...

???
 
Building on your solution, my first thought is to export a 1 column delimted file. I don't think you'll get stuck with a delimeter at the end....


Alternately since you are already writing this thing record by record in code, you could simply write directly to a text file. I want to say that the File~System~Object is the way to do it. It has been a while but you should find an example around here easily.

BTW... you posted in the forms forum. I would have posted this in the VBA forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top