Solved

Error 3011 - object not defined with VBA - using DoCmd.TransferText in a macro

Posted on 2004-03-27
4
657 Views
Last Modified: 2012-05-04
Here is the code.  Please let me know what is wrong.  I tried to run this within Word and / or Excel.  Got the same error.

Sub Main()
Dim ACObject As Object

Set ACObject = CreateObject("Access.Application")
With ACObject
    .OpenCurrentDatabase "c:\testme.mdb", False
    .DoCmd.TransferText acExportDelim, "Alpha Export", "Alpha", "c:\test.txt"
    End With
ACObject.Close
ACObject.Quit
Set ACObject = Nothing
End Sub

Object not defined refers to the c:\test.txt file.


Thanks,
Russ
0
Comment
Question by:RUSS_EMI
4 Comments
 
LVL 22

Expert Comment

by:Dreamboat
ID: 10699392
Russ:
If I were you, I'd place a 20-point "pointer" question in the Access topic area to this Q.
:)
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 10699542
This is copied from another source on the internet....
http://support.cai.com/helpfiles/as61help/ASMGRError_3011.html

Explanation:

There can be several reasons for this error message:

1. The file doesn't exist.

2. The file is in use by another application which has it open in exclusive mode, and the file hasn't been flagged as shareable.

3. You do not have the proper rights to this directory or file.

4. The path to this file is incorrect.


It also suggests that you may want to export everything from your database, recreate it and then re-import.  Perhaps a corrupt db.

0
 

Author Comment

by:RUSS_EMI
ID: 10701230
The file doesn't exist is correct.  I'm trying to export data to it, shouldn't the file "c:\test.txt" be created?  
Changing "Ex"port to "Im"port works; that is, where the file does exist and is populated with data.  
This is on a stand alone machine.  
The db only consists of two fields (1 record); id (autonumber) & field1 ("a").  
I created it.  
Russ
0
 
LVL 6

Accepted Solution

by:
bkpchs237 earned 125 total points
ID: 10710020
RUSS_EMI,

Reading your docmd statement indicates that you have a specification named: "Alpha Export"
and a table named: "Alpha".  What happens if you eliminate the specification?

I ran this modified code and it worked for me just fine after adding a reference to the Access library
thru Tools, References.  I eliminated the Close command as well as it is not supported or necessary.

Sub Main()
Dim ACObject As Object
Set ACObject = CreateObject("Access.Application")
With ACObject
    .OpenCurrentDatabase "c:\testme.mdb", False
    .DoCmd.TransferText acExportDelim, "", "Alpha", "c:\test.txt", False, ""
    End With
ACObject.Quit
Set ACObject = Nothing
End Sub


Hope this helps.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
Outlook Free & Paid Tools
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question