Solved

Problem export query results

Posted on 2004-09-10
14
387 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
  • 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
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!

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

685 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