Button Functionality

  • Thread starter Thread starter Dale Clarke
  • Start date Start date
D

Dale Clarke

Hello,

I need some help from the group. I have a button on a form that when
clicked, runs a select query. I need to add some additional code to the
button so that after the query runs, it then saves the results in an
Excel format with a set file name and then exports the file to a
specific directory on my hard drive. Is this possible and if so where
might I find an example of how to write the code. Any help would be
greatly appreciated.
 
you don't need to open the Select query first. just replace the OpenQuery
code in the procedure with the following:

DoCmd.OutputTo acOutputQuery, "MyQueryName", _
acFormatXLS, "C:\MyFolder\MyFile.xls"

see the OutputTo Method and OutputTo Action in VBA Help for details.

hth
 
Thanks tina, it worked great!!
you don't need to open the Select query first. just replace the OpenQuery
code in the procedure with the following:

DoCmd.OutputTo acOutputQuery, "MyQueryName", _
acFormatXLS, "C:\MyFolder\MyFile.xls"

see the OutputTo Method and OutputTo Action in VBA Help for details.

hth
 
Back
Top