View Full Version : I hope that this is simple


twlight
04-26-2007, 04:18 PM
I am very rusty on my VB and am having trouble with this. I will do my best to explain what I am trying to do. I have one table with about 8 fields that I need to export records out of. The trick is that I need to export this data into an individual text file for each record.

I know that this should be simple, but I am having no end of trouble doing this. Any help would be great!

Twlight

Dennisk
04-26-2007, 11:22 PM
as a programmer I would read each record and open a new output file and just write the data. Read the next record and repeat the operation until end of file.

wordstar
04-28-2007, 05:07 PM
Skipping some detail:

OPEN "FILE.TXT" FOR OUTPUT AS #1
Set RS = currentdb.OpenRecordSet("MyTable")
with RS
.MOVELAST : .MOVEFIRST 'populate & go to top
fmax = .fields.count - 1
OUTLINE = "" 'buffer for output
do 'scan the input table
for f = 0 to fmax 'BUILD THE OUTPUT LINE
OUTLINE = OUTLINE & .fields(f) & "," 'you'll have to deal with the trailing comma
next f
PRINT #1, OUTLINE 'READ THIS LATER WITH 'LINE INPUT'
'AND PARSE THE LINE WITH 'SPLIT()' FUNCTION
.movenext 'next input table record
LOOP UNTIL .EOF
.CLOSE
END WITH
CLOSE #1

Hoping to be helpful,
Leonard