Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem export query results

Posted on 2004-09-10
14
Medium Priority
?
402 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

610 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