Microsoft Office Access to database could not find object

I created a test MS Access database to export a table to Excel and a text file.

This works for Excel:

DoCmd.OutputTo acOutputQuery, "QryExportToExcel", _ acFormatXLS, XFile, False 

I created a specification for a text file and used this code

 DoCmd.TransferText acExportDelim, "Mytable Import Specification", "mytable", "D:\myfolder\test1.txt", False 

In the error message, I get "test1 # txt" .

Microsoft Office Access database engine cannot find object
"Test1 # .txt". Make sure the object exists and that you write its name
and the way is right.

Error which i got

I tried to create test1.txt in the same way. To my surprise, this deleted the file that is already present.

Software: MS ACCESS 2007

+5
source share
4 answers

Microsoft Office Access databasse could not find object "test1 # txt". Make sure that the object exists and that you name its name and path correctly.

This is a general (and rather useless) error message that Access displays in case something goes wrong. One example would be a field name with an error in the import / export specification.

You can get a “real” error message by trying the import operation “manually” in the Access user interface (and not through the code).

+1
source

The author of the question said that the problem was "because I used the import specification to export the file."

They solved the problem with the export specification.

+1
source

Since you are doing DoCmd.TransferText, Access expects the Test1.txt file to exist in this place. Try creating a file first, and then wrap the text.

You can try this code before exporting to create a file:

 Public Sub CreateExportFile() Dim strFileName As String Dim SomeStringToOutput strFileName = "d:\myfolder\test1.txt" Open strFileName For Output As #1 End Sub 
0
source

I had a similar situation, and I found that the schema.ini file is in the destination folder. This was created when acExportMerge was executed earlier and caused this error. Make sure the file has been deleted before executing the new TransferText.

0
source

All Articles