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 May 1st, 2007, 07:21 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Run Time Error 3011

Help!

Run Time Error 3011
The Microsoft Jet database engine could not find the object 'bla-bla-bla' Make sure the object exists and you spell its name and the
path name correctly."

I have a directory with many files, each of which I
import to Access, and then a generate report). The
offending code that produces the error is listed below,
but the error occurs ONLY the first time that it is run
after opening the mdb file. If I import manually once,
then the code runs perfectly. Is there a way to do this
without having to "prime the pump"??

Code follows:

fileName = Dir("c:\downloads\*.csv", vbNormal)
Do While fileName <> ""
  DoCmd.TransferText
acImportDelim, "ImportSpecs", "rawCSV", fileName, False '
crashes on this line
  Call GenerateReport
Loop


Reply With Quote
  #2 (permalink)  
Old May 2nd, 2007, 12:25 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This is not all the code here to import a text file. Is that what you are trying to do and it is not working (the import part?)



mmcdonal
Reply With Quote
  #3 (permalink)  
Old May 2nd, 2007, 03:03 PM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually....for the sake of stating this problem..there is enough code shown. After the DIR command....and you drop down to the
acImportDelim, "ImportSpecs", "rawCSV", fileName, False ' line...it blows up with the Run Time Error 3011 stating that it cannot find the file that is contained in the value of variable "FileName". It is a problem since it was the DIR command that populated the value into the variable "Filename". Yet...if you import a file "manually" first....this code or code like it....WILL WORK FINE! That's the dilemma of this error. This error is raised on this bit of code, UNTIL, you go ahead and import a file manually 1st.

Reply With Quote
  #4 (permalink)  
Old May 3rd, 2007, 06:38 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can recurse a folder or folders, and take the filenames, either one at a time, or all at once into an array. For example, this script recurses every folder on my desktop, and shows me every jpg file by path and filename:

Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubFolders FSO.GetFolder("C:\Documents and Settings\MyUserName\Desktop\")
Sub ShowSubFolders(Folder)
    For Each SubFolder In Folder.SubFolders
        Set demofolder = FSO.GetFolder(SubFolder.Path)
        Set filecoll = demofolder.Files
        For Each fil in filecoll
            sJpg = Right(fil.Name, 3)
            If sJpg = "jpg" Then
                WScript.Echo SubFolder.Path & ": " & fil.Name
            End If
        Next
        ShowSubFolders SubFolder
    Next
End Sub

Using this, you can find the csv files in your folder structure, or just use a single folder, and then you can try to import them, or you can read them line by line. I do both in various applications.

The code you posted is incomplete to do this.

HTH


mmcdonal
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 11:17 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 01:28 PM
Error 3011 after installation to another pc bluebear VB How-To 1 February 26th, 2007 09:59 AM
run time error ashishroyk Java GUI 0 October 8th, 2004 01:42 AM
Run Time Error JBond Access VBA 0 May 27th, 2004 09:50 AM



All times are GMT -4. The time now is 07:17 PM.


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