Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export query with command button

Status
Not open for further replies.

jer007

Technical User
Feb 16, 2004
94
0
0
CA
I have a form that a user fills out to specify the criteria to run a query. It then generates reports based on the queries. I now have a new query that rather than being used in a report needs to be exported to Excel and e-mailed out. If possible this is what I am trying to achieve:

1. Run query from form and export into MS-Excel (.xls)
2. Format a numerical column in the excel spread sheet to have 3 decimal places
3. Attach the new Excel file to e-mail.

With the exception of number 2 I can do this manualy using the File -> Send To -> Mail Recipent option. It is not important that the data be added to an existing excel file. It can overwrite the file each time.

I don't have a clue how to do this so any help that can be given would be greatly appriciated.

Thank You.
 
Hi
Docmd.SendObject will do 1 and 3, but the only way I could get 2 with this set-up was to format the field in the table to four decimal places:
[tt]DoCmd.SendObject acSendQuery, "qrySend", acFormatXLS, "email @ co.ext", , , "Your Report", "Hi", True[/tt]

There is a longer way around with TransferSpreadsheet, modifing the sheet, and using Outlook. You will find a good deal on all these topics in the FAQs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top