J
jmonty
Ok. Still a little cloudy, but I think what you said was
that you can clean the file up into a 3 column ("neat-
rowed") table (Table1) right?
Again make sure the field sizes are set to the correct
length, then loop throught the records creating a new
fixed-width text file:
Field1 & 2 are the names of the fields in your table, use
as many as you need. Use Trim to remove any leading or
trailing spaces and format them to the Field Size as I
described in the last post:
Sub ExportTextFile()
Dim db As Database
Dim rst As Recordset
Dim Directory As String
Dim MyString As String
Set db = CurrentDb
'Get the current directory and create new
'textfile for output
Directory = (Mid(db.NAME, 1, Len(db.NAME) _
- Len(Dir(db.NAME))))
Open Directory & "\TestOutput.txt" For Output As #1
Set rst = db.OpenRecordset("Table1", dbOpenDynaset)
rst.MoveFirst
Do While Not rst.EOF
MyString = Format(Trim(rst![Field1]),"@@@@@@@@@@") _
& Format(Trim(rst![Field2]), "00000.00" & Chr(13)
Print #1, MyString
rst.MoveNext
Loop
Close #1
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
Look in the same directory that the db resides in for the
new fixed-width text file named "TestOutput.txt"
Use this new, clean file to import.
Hope this helps.
that you can clean the file up into a 3 column ("neat-
rowed") table (Table1) right?
Again make sure the field sizes are set to the correct
length, then loop throught the records creating a new
fixed-width text file:
Field1 & 2 are the names of the fields in your table, use
as many as you need. Use Trim to remove any leading or
trailing spaces and format them to the Field Size as I
described in the last post:
Sub ExportTextFile()
Dim db As Database
Dim rst As Recordset
Dim Directory As String
Dim MyString As String
Set db = CurrentDb
'Get the current directory and create new
'textfile for output
Directory = (Mid(db.NAME, 1, Len(db.NAME) _
- Len(Dir(db.NAME))))
Open Directory & "\TestOutput.txt" For Output As #1
Set rst = db.OpenRecordset("Table1", dbOpenDynaset)
rst.MoveFirst
Do While Not rst.EOF
MyString = Format(Trim(rst![Field1]),"@@@@@@@@@@") _
& Format(Trim(rst![Field2]), "00000.00" & Chr(13)
Print #1, MyString
rst.MoveNext
Loop
Close #1
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
Look in the same directory that the db resides in for the
new fixed-width text file named "TestOutput.txt"
Use this new, clean file to import.
Hope this helps.