Use Form and VBA to Send Query Results to Excel

R

ryguy7272

I thought a simple sub, such as the following, which I found on this DG,
would allow me to copy/paste the results of a Query to an Excel SS:

Private Sub Command1_Click()
Dim stDocName As String
stDocName = "qryCurrentQ"
'This code does not work
DoCmd.OutputTo acOutputReport, stDocName, acFormatXLS, "c:\Current.xls"
End Sub

All this does is delete the Worksheet (Current.xls) that resides on the C:
drive and...that's it. How can I send the results of a Query to an Excel SS?

Regards,
Ryan---
 
R

ryguy7272

You are totally right! I forgot about this little trick. I created the
Macro, saved it to a Module, and called that Function with a Command1_Click
button. Thanks for the reminder about this technique. The old code is gone
and the new code is running smoothly...


Regards,
Ryan---
 

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