Solved

Problem export query results

Posted on 2004-09-10
14
394 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

691 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