Solved

Problem export query results

Posted on 2004-09-10
14
347 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 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
ID: 12030995
well, try changing it and run the codes again.
0
 
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 119

Expert Comment

by:Rey Obrero
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero 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 119

Expert Comment

by:Rey Obrero
ID: 12044779
u r welcome!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now