View Single Post
  #1 (permalink)  
Old February 28th, 2012, 08:37 PM
Luckdress Luckdress is offline
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Lightbulb Access 2007 Run Time Error 3011

Can someone please help? I am trying to import all text files in a folder to an Access dB, but I am getting an error when I run the code below.

Error 3011 -"The Microsoft Office Access database engine could not find the object (filename). Make sure the object exists and that you spell the name and the file path name correctly",
I am passing the full path name to the transfer function using a textbox named txtImportPath1 on a form. The textbox is populated by browsing to the folder and picking up the full path.
The error message picks up the name of the first text file in this folder that it says it cannot find.
Please help!

Code:
 strFolderPath = Me.txtImportPath1
    Set objFS = CreateObject("Scripting.FileSystemObject")
    
     If objFS.FolderExists(strFolderPath) = False Then
            MsgBox strFolderPath & " Folder Not Found ", vbCritical, "File Import"
            Exit Sub
    End If
    
    Set objFolder = objFS.GetFolder(strFolderPath)
    Set objFiles = objFolder.files
        For Each objF1 In objFiles
         If Right(objF1.Name, 3) = "TXT" Then
               
     On Error Resume Next
    ' Drop previous Temp table before linking to the new text file
    ' If table not found go to next line
      DoCmd.RunSQL "DROP TABLE tbl_TempWKS"
    
         ' Link to the text file and import file to the specified table using the specs provided
       DoCmd.TransferText acLinkDelim, "WKSpecs", "tbl_TempWKS", objF1.Name, True
Reply With Quote