Solved

Export to csv not working

Posted on 2015-01-16
20
192 Views
Last Modified: 2015-01-22
I'm using this on click code to export query results to a csv file.  It works fine on a computer running Windows 7 but doesn't work on a computer running Windows 8 or at least I think that is the problem.  

Can someone help?

The error I get is Run-time error 3011.  The Microsoft Access database engine could not find the object.....  Make sure the object exists ....  

Here's the code:

DoCmd.TransferText acExportDelim, , "qryExportRecordsEmailList", "C:\Email List.csv", False
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 2
  • +3
20 Comments
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40554708
Can you try something like this:
DoCmd.TransferText acExportDelim,"Standard Output", _
     "qryExportRecordsEmailList", "C:\Email List.csv",-1

Open in new window

or
DoCmd.TransferText acExportDelim,,"qryExportRecordsEmailList", "C:\Email List.csv",-1

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40554809
Make *sure* that "qryExportRecordsEmailList", ...is spelled *exactly* as it is in the navigation pane...
Misspelling the query will result in the error you are getting...
...also make sure that this query even exists.

JeffCoachman
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40555052
I assume that your file with the macro is exactly the same on both windos 7 and 8. Correct?

Nothing was changed but Windows 8 gets an Run time error?

If this is the case, go to my first answer and give it a try: ID: 40554708
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:SteveL13
ID: 40555149
Jeffrey:  Yes, spelling is perfect and the query definitely exists.  Remember, it does work on my computer but not the computer running Windows 8.  But I'm not sure the Windows version has anything to do with it.

Wilder1626:  Suggestion 1 does not work.  Probably because there is no "Standard Output".  Suggestion #2 does work on my computer but not the Windows 8 computer.
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40555179
Do you already have a file  List.csv in this path:  C:\Email List.csv

If not, can you create it and then, try again your command?

If it works, then you can try to add this code before you create the file, to prevent the Run time error:

Dim strFileName As String
 Dim SomeStringToOutput

 strFileName = "C:\Email List.csv"
 Open strFileName For Output As #1

Open in new window

0
 

Author Comment

by:SteveL13
ID: 40555228
Wilder1626:  I created a file named Email List.csv and put it in C:\Email List.csv

Then tried again on the computer that it doesn't work on and it still failed.

Actually I had tried this yesterday when the situation first came up.
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40555230
what are the Microsoft office version on both PCs?
0
 

Author Comment

by:SteveL13
ID: 40555236
2013
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40555253
Have you validated your MS access export specification setting on your new PC?

Compare both settings from the 2 PC MS Access file.

It may be a date format issue or a delimiter.
0
 

Author Comment

by:SteveL13
ID: 40555258
There is no saved export spec.  The code is just:

DoCmd.TransferText acExportDelim, , "qryExportRecordsEmailList", "C:\Email List.csv", False
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40555274
At this point, i'm out of ideas. sorry.

Normally, it should work at this point, after validating all comment from Jeffrey Coachman and I.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40555424
Steve,

FWIW, I never export to CSV without an export spec.

Just for fun, create an export spec to do this, (Settingthe comma as the delimiter explicitly) ...then insert it in the ExportSpec argument of TransferText command.
Give it a try

Jeff
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40555458
If you can also review this link , if this is a new setting for you:

Export data to a text file
0
 

Author Comment

by:SteveL13
ID: 40555506
Ok.  So I created a spec and have this line of code.  But now I get an error:

Run time error 3625.  The text file specification..... does not exist.....


Code:

DoCmd.TransferText acExportDelim, "Email List", "C:\Email List.csv", False
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40555512
Can you please validate one last time and confirm below?

1.Open your Microsoft Access database.
2.Under the External Data tab, click Text File in the Export section.
3.Enter a destination for your file or use the Browse tool, then click OK.
4.In the Export Text Wizard, choose Delimited and click Next to continue.
5.Choose Comma as the delimiter.
6.Select Include Field Names On First Row.
7.Set Text Qualifier to double quotation marks.
8.Click Next, then click Finish.
0
 

Author Comment

by:SteveL13
ID: 40555532
This is validated.  I did it again but now won't have access to the Windows 8 computer until early next week.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 40555557
I would double/triple check...

1.  Jeff's suggestion.  That qryExportRecordsEmailList does indeed exist on your Windows 8 computer, at the time the code executes.  (Just as an example, a query created on the fly by code will be missing if the code fails to execute).    

Just for Yuks, try the same command with a different query or table, using the problematic Windows 8 machine:

DoCmd.TransferText acExportDelim, , "SomeOtherTableName", "C:\Email List.csv", False

2.  Is the code, beyond a shadow of a doubt stopping at that exact line?

3.  When the error appears, and you click debug, is there any part of the statement that appears 'selected'?
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 40556559
This should work, with your names, provided that the query exists (and does not have criteria or parameters), and all the arguments are set correctly:

   DoCmd.TransferText transfertype:=acExportDelim, _
      specificationname:="CustomerExportSpecs", _
      tablename:="qryCustomers", _
      FileName:="D:\Documents\Examples\Export Delimited.csv", _
      hasfieldnames:=True

Open in new window


If the query does have criteria or parameters, change it to a make-table query, run it, and then try to export the table created by running the make-table query.

If the problem is that the export spec doesn't exist on the Windows 8 computer, you may have to recreate it.
0
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40557541
The reason for your error is very simple:
In Windows 8, you are not allowed to create files in the root of the systemdrive.

This will work:

DoCmd.TransferText acExportDelim, , "qryExportRecordsEmailList", "C:\MyExportFolder\Email List.csv", False

/gustav
0
 

Author Closing Comment

by:SteveL13
ID: 40564794
Yes, I ended up sending it to C:\Special Folder\xxxxxx.csv

Could not go to the C drive even though it DID work on another Windows 8 computer.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

761 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