Help with Importing Text file

Gremlin76

New member
Local time
Today, 06:46
Joined
Mar 28, 2001
Messages
4
I am having a couple problems with importing information from a text file.
My first problem is getting Access to accept the type of text file it is. The file is save as FileName.rpt and Access doesn't seem to like the .rpt file extention. I have started by using DoCmd.TransferText, for example

DoCmd.TransferText acImportDelim, "Import Spec", "ToTableName", "C:\Filenamelocation.rpt", False

I can open the .rpt file in wordpad and resave the file as a .txt (file looks fine in wordpad no unrecognizable characters or anything out of place). Running the code above using a .txt file name works great, but I get a Run-Time error "3207", Cannot Update, Database or Object is Read Only when using .rtp file.

My second problem is, is this the best way to go about getting the information from the file. I am trying to automate a process that currently involves 3 excel spreadsheets, transferring data by hand, and another database and also store the information in a more usable format for the future use and review. The .rpt file is a report file generated by an instrument in our laboratory. It is not delimited in any uniform manner. The plan is to use the transfertext command (using a space delimited specification) to pull the file to a temporary table and then use code to pull specific the specific fields from specific rows from the temp table. Since the file is not delimited, using the space delimited import generates a table that has about 80 fields and 200 records. Also for this to work the information in the file must be in the exact same location everytime (I'm not sure yet if it is and this is a concern). Is there a better way to go about this?
Thank you
sTeven
 
Last edited:
See this Thread on your .RPT extension problem, I assume you are using A2K or higher. Reading and writing these extensions are handled the same in Access.
 
Thanks for the link. We are using A2K.
We can export to a .txt file but it is a couple of manual steps that I was hoping to avoid (the software generating the file does not have the option of changing the file extensions used) and I don't want to mess with system registries.
Can file names be changed by using code? The transfertext worked fine by changing the .rpt extension to .txt in file explorer.
Thanks again
sTeven
 

Users who are viewing this thread

Back
Top Bottom