danmc18
Aug 23 2004, 11:09 AM
Good afternoon,
I have a text file which i want to import into a table, it is made up of 3 lines; 1st line is supplier address - 2nd line is the order - 3rd line is customer address. each line needs a different import specification. does anyone know of a way to pull this text file into access?
cheers
dan
curtswanson
Aug 23 2004, 11:54 AM
The sub below will take the three line file "Input.txt" and split it into "Input1.txt", "Input2.txt", "Input3.txt".
Sub SplitText()
Const myPath = "C:\My Stuff\"
Const myInFile = "InputFile"
Const myFileType = ".txt"
Dim i As Integer
Dim inputline As String
Open myPath & myInFile & myFileType For Input As #1
For i = 1 To 3
Line Input #1, inputline
Open myPath & myInFile & i & myFileType For Output As #2
Print #2, inputline
Close #2
Next i
Close #1
End Sub
danmc18
Aug 23 2004, 12:01 PM
thats excellent mate, thanks very much. is it possible for these files to be removed once the import has completed?
dan
curtswanson
Aug 23 2004, 12:05 PM
You're welcome.
Sub KillMyFiles()
dim i as integer
for i = 1 to 3
kill myPath & myInFile & i & myFileType
next i
end sub
Use the same constants as previous.
danmc18
Sep 2 2004, 09:23 AM
Alright mate, thanks for the previous help. i've got another question for you. i need to export to a file made up of three separate exports ie three text files which need to be made into one file, and given a filename of the current date and time (ddmmyyyyhhmm). pretty much my initial problem except the other way around
any ideas?
dan
Clippit
Sep 3 2004, 10:09 PM
How do the records in the output need to be sequenced? How do they need to be formatted. Rather than doing htree exports and interleaving the records (the opposite of the solution above) you ,ay be better to do the export via code, where you could write out the records just the way you want to. There is a sample of this approach at
this link.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.