Button Functionality

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.
 
T

tina

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
 
D

Dale Clarke

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top