[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-03-27
4
Medium Priority
?
697 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

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