Solved

Problem export query results

Posted on 2004-09-10
14
390 Views
Last Modified: 2012-08-14
I am trying to export the result of a query named qryExport_results.  I am using the following to do so:

DoCmd.TransferText acExportDelim, , "qryExport_results", strSaveFileName, True

The problem is that I get an error stating "Query must have at least one destination field".  I am not sure what I am doing wrong.  I tried to just disply the query to make sure it was working ok, and it appears it is.  I am lost.

Thanks!
0
Comment
Question by:maianoel
[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
  • 6
  • 6
  • 2
14 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12030475


DoCmd.TransferText acExportDelim, , "qryExport_results", strSaveFileName, True
--------------------------------------------------------------------^^^^^^^^^^ this must be a path

like "C:\Filename"
0
 

Author Comment

by:maianoel
ID: 12030600
Does it have to be a path?  Right now I am using the microsoft Save file dialog box to specify the path, which I am then assigning to strSaveFileName.  It works OK for tables, but maybe queries are different?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12030995
well, try changing it and run the codes again.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12031269
What type of query is qryExport_results? Is it a SELECT query?
0
 

Author Comment

by:maianoel
ID: 12043516
OK, I tried changing the path to C:\results.csv and I still get the same error.

It's a SELECT query.  the code is as follows:

SELECT *
FROM cbsofeed_less
WHERE (((cbsofeed_less.Trunc_Acct)="03594364") AND ((CDate([Month]))=#8/1/2004#))
ORDER BY cbsofeed_less.Inv_Date;
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12043569
try changing this

C:\results.csv

to

C:\results.txt
0
 

Author Comment

by:maianoel
ID: 12043774
ok, changing it to c:\results.txt worked fine.  Is there a way to make this work with either .csv files or .xls files? (I get the same error when exporting to an excel file).  I don't want the users to have to import the file into excel manually.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12043819
try adding to your references
Microsoft Excel xx Object library

tools>references
0
 

Author Comment

by:maianoel
ID: 12044249
Nope, that did not work either.  Still get the same error message.  Could there be something wrong in my DoCmd statement?  Funny that it works fine with a table, but not with a query.
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12044309
Are you trying to export to an xls file? If you are, you have to use TransferSpreadsheet - TransferText will not let you export to file extensions other than csv and txt.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 12044348
no, I don't think so. I've been using the same format and all is working fine.
one more thing
try adding the Microsoft Office xx Object library then do a debug>compile.

if still you are getting the problem, can you zip your db and mail to me
email at profile.
0
 

Author Comment

by:maianoel
ID: 12044479
shane, right now I am just trying to export the query results to a .csv file so the users can open it up in excel easily.  after trying capricorn's suggestion above, it appears it will export to .txt just fine, but for some reason won't to .csv.

capricorn1, I will give your suggestion a try now and let you know.

Thanks to both of you for you help and suggestions!
0
 

Author Comment

by:maianoel
ID: 12044590
Well, I added the Micrososft Office XX object library and then did a debug>compile (this alone was nice as I was able to get rid of some redundant code I had from early on) and all works perfectly now.  Thanks for your help!
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12044779
u r welcome!!!
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

734 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