So what are you really trying to do? Export each individual record to
a separate text file?
Andromeda031 - 07 Oct 2007 03:16 GMT
Yes, that's correct!
> So what are you really trying to do? Export each individual record to
> a separate text file?
> Hi everyone!
>
[quoted text clipped - 52 lines]
>
> Hi, I don't know if this is helpful, but I have written some code to send banking data to a text file. In my case I get data from 3 different tables into ONE text file, but if you were to bring the opening / closing of each file into the loop, maybe that would work. To delete previously created files, "Kill FilePathAndName can be coded in... Even if it does not help directly it might give you an idea...
Private Sub SubCreateTextFile()
'=======================
Dim MyDB As Database
Dim MyRS As Recordset
Dim FilePathAndName as string
Set MyDB = CurrentDb 'Define Database
'First Step: Select Export Table for Header
Set MyRS = _
MyDB.OpenRecordset("TblTxtExportToBank1", dbOpenDynaset, dbSeeChanges)
'Open File ready to write to
FilePathAndName = "C:\MyFolder\MyFileName.txt"
Open FilepathAndName For Output As #1
'Write Statement Header to File
MyRS.MoveFirst
Print #1, MyRS![RecordType] & ",,,," & _
MyRS![MyAccountNo] & "," & _
MyRS![BatchType] & "," & _
MyRS![BatchDueDateYYMMDD] & "," & _
MyRS![TodayYYMMDD] & "," 'Indicator blank field as end
MyRS.Close 'End Header Record
'2nd Step Select Transaction Table for Transaction Records
Set MyRS = _
MyDB.OpenRecordset("TblTxtExportToBank2", dbOpenDynaset, dbSeeChanges)
'Write Transactions to File
MyRS.MoveFirst
Do Until MyRS.EOF
Print #1, MyRS![RecordType] & "," & _
MyRS![AccNo] & "," & _
MyRS![TransactionCode] & "," & _
MyRS![Amount] & "," & _
MyRS![AccountName] & "," & _
MyRS![Reference] & "," & _
MyRS![Code] & ",," & _
MyRS![Particulars] & "," & _
MyRS![SubscriberName] & ",," & _
MyRS![CMIRef] & "," & _
MyRS![CMIPart]
MyRS.MoveNext
Loop
MyRS.Close 'End Transaction Records
'3rd Step Select Summary Table for Control Records
Set MyRS = _
MyDB.OpenRecordset("TblTxtExportToBank3", dbOpenDynaset, dbSeeChanges)
MyRS.MoveFirst
Print #1, MyRS![RecordType] & "," & _
MyRS![BatchTotal] & "," & _
MyRS![CountRec] & "," & _
MyRS![HashTotal]
MyRS.Close 'End Control Record
Close #1 'Close Text file
Set MyDB = Nothing
End Sub
>
>
>