Import text file plus adding a field

Beady

Registered User.
Local time
Today, 17:06
Joined
Dec 18, 2000
Messages
24
Hi,

I'm importing the contents of lots of text files using a combination of a loop and DoCmd.TransferText.

This works fine and I can get the contents of several hundred files in a few seconds. The files are called 1.dbb, 2.dbb... and each has an associated image file, 1.bmp, 2.bmp... etc. After the import I move the files to a new folder.

I need to create a link to the bmp file but this information is not included in the text file so I need to rely on a field which contains the file name.

How can I populate a field at import time to include the name of the imported file?

Anyone give me a clue please.

Regards,

Bernard D
 
You would need to open the text files, read a line, determine the bitmap filename, then add the row/line to your import file. All programatically.
 
Thanks for the quick response, however the file does not contain the name of the bitmap, that would be too easy.

The bitmap will be called exactly the same as the text file apart from the extension.

What I need to do is to intercept the filename as I am using the DoCmd.TransferText and use that value to populate a field in the same record that is currently being imported.
 
Imports are done as a batch and you cannot manipulate each row as that is all done for you in the transfer text method. If you know the name of the file then you will have to import the data from the text file row by row using the OPEN Statement to Open the text file, then read each row using LINE INPUT To read each line. Also Open the Import Target table using DAO or ADO and wite the data on a row by row basis.

The other alternative is again open the text file and write a new text file containing the aditional data then import that file.
 
OK, I had a feeling that it would be something like that.

Cheers,

Bernard D
 

Users who are viewing this thread

Back
Top Bottom