[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Trying to export query data

Posted on 2013-06-11
6
Medium Priority
?
360 Views
Last Modified: 2013-06-11
I am trying to export the results of a query with:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryDistinctEmailAddresses", "C:\EmailAddressExport", True

but am getting a runtime error (see attachment)

Also, instead of exporting the Excel file to the user's C drive I want it to go to the user's desktop.
0
Comment
Question by:SteveL13
6 Comments
 
LVL 49

Expert Comment

by:Dale Fye
ID: 39237981
1. no attachment included.

2.  Try adding a file extension (.xlsx) to the output file name
0
 

Author Comment

by:SteveL13
ID: 39238077
Sorry... attachment here.
runtime-error.jpg
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 39238134
You only have the path. A filename is needed too, like:

"C:\EmailAddressExport\MyExport.xlsx"

/gustav
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:SteveL13
ID: 39238359
Now I have this...

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryDistinctEmailAddresses", "C:\EmailExport\EmailAddresses.xlsx"

But when I try to open the Excel file I get the attached error.

??
error2.jpg
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 39238441
Seems like you don't have the correct version of Excel.
Try to create an older *.xls file with:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qryDistinctEmailAddresses", "C:\EmailExport\EmailAddresses.xls"

/gustav
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39238521
if you are using A2003, use this

DoCmd.TransferSpreadsheet acExport, 8, "qryDistinctEmailAddresses", environ("userprofile") & "\Desktop\EmailAddresses.xls", True

if you are using A2007 or greater use this

DoCmd.TransferSpreadsheet acExport, 10, "qryDistinctEmailAddresses", environ("userprofile") & "\Desktop\EmailAddresses.xlsx", True
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

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…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

830 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