Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2012, 08:37 PM
Registered User
 
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
 
Old February 29th, 2012, 02:42 PM
Authorized User
 
Join Date: Jan 2011
Posts: 86
Thanks: 1
Thanked 12 Times in 12 Posts
Default

Hi,

to be sure to work with the full path for the file, try using
Code:
 objF1.Path
The Following User Says Thank You to disel2010 For This Useful Post:
Luckdress (March 1st, 2012)
 
Old March 1st, 2012, 12:24 PM
Registered User
 
Join Date: Feb 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by disel2010 View Post
Hi,

to be sure to work with the full path for the file, try using
Code:
 objF1.Path
Thank you disel2012. It turned out that my objF1.Name did not capture the full path. I added strFolderPath and it worked!
Yesterday 10:42 AM





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Run Time Error 3011 joebob_houston Access VBA 3 May 3rd, 2007 06:38 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 02:28 PM
Error 3011 after installation to another pc bluebear VB How-To 1 February 26th, 2007 10:59 AM
Run-time error 7: Out of Memory - Access 2002 alexisb BOOK: Expert One-on-One Access Application Development 4 October 12th, 2004 12:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.