Using command button in a form to export a report

  • Thread starter Thread starter Alex Martinez
  • Start date Start date
A

Alex Martinez

Hello,


In my form I like to export a report that will automatically save as an
Excel file using a command button or a tool bar button. What I am currently
doing is saving the file in a save dialog box and selecting Excel in the
Save as type and naming the file. Now the name of the file will not change.
Now this is a process that my users seem to have problems with. Is there a
easier or quicker way of saving the file into an Excel format? The reason I
am doing this is the various user will receive the Excel report via e-mail
and will update the report and send it back to the administrator. Who will
update the database. Any tips or website to visit will be appreciated.
Thank you in advance.
 
Hi Alex

I think what you need is to create a query that contains all the fields,
filtering etc that you need to get the required data. (You may have already
done this as the source for your report)
Then your button will open this query and then save it as an excel file
Something like
DoCmd.OpenQuery "QueryName", acNormal, acEdit
DoCmd.OutputTo acQuery, "QueryName", "Microsoft Excel(*.xls)", "",
False, ""
DoCmd.Close acQuery, "QueryName", acSaveYes

The OutputTo has various options that you can see from access help

HTH

John
 
Back
Top