Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 28th, 2012, 08:37 PM
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
  #2 (permalink)  
Old February 29th, 2012, 02:42 PM
Authorized User
Points: 448, Level: 7
Points: 448, Level: 7 Points: 448, Level: 7 Points: 448, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 85
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
Reply With Quote
The Following User Says Thank You to disel2010 For This Useful Post:
Luckdress (March 1st, 2012)
  #3 (permalink)  
Old March 1st, 2012, 12:24 PM
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
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 12:17 PM
Run Time Error 3011 joebob_houston Access VBA 3 May 3rd, 2007 07: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 01:11 PM



All times are GMT -4. The time now is 01:22 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.