Access to excel

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I open up the result of an access query into excel, from within
access?

Thanks

Regards
 
Can you clarify? Do you want to export an ACCESS query into EXCEL
spreadsheet? If yes, check out the TransferSpreadsheet command (macro or VBA
code).
 
Hi John,

Create a command button on a form, and name it cmdExportToExcel. Then add the following
code to this button's click event procedure. The OutputTo method includes an option to
specify Autostart as either true (-1) or false (0). The default is false is you do not
specify this option. This code will save a query named "qryMyQuery" as an Excel
spreadsheet named "MySpreadsheet" in the same folder that the database is placed into.

Private Sub cmdExportToExcel_Click()
On Error GoTo ProcError

Dim strPath As String
strPath = CurrentProject.Path

DoCmd.OutputTo acOutputQuery, "qryMyQuery", acFormatXLS, _
strPath & "\MySpreadsheet.xls", AutoStart:=-1

ExitProc:
Exit Sub

ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in cmdExportToExcel_Click event procedure..."
Resume ExitProc
End Sub



Tom
_______________________________________


Hi

How can I open up the result of an access query into excel, from within
access?

Thanks

Regards
 
Back
Top