Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Download:

Datei 1: Access_Export_Query.accdb
Datei 2: Output_Results.xlsx

 

 

The example shows how to export an Access query to Excel.

The query contains current data from a table, which was filtered by a radio button.

For this you use the command Docmd.OutputTo in Microsoft Access

As

DoCmd.OutputTo acOutputQuery, "qryCars_Sale", acFormatXLSX, , True

 

 

When executing the OutputTo command, a Save dialog box is automatically displayed which would like to save a document in Excel.

DoCmd.OutputTo acOutputQuery, "qryCars_Sale", acFormatXLSX, , True

 

The acOutputQuery parameter indicates that a query is in the third parameter.

 

The query query is bound to the form that is currently open and uses a radio button.

 

If you want to output the output directly into a named Excel file, then you have to name the Excel file name with the foll path

Dim sFilename As String

    sFilename = "C:\_Daten\Desktop\Demo\Access\2018-01-02 Access Export Query\Output_Results.xlsx"

    DoCmd.OutputTo acOutputQuery, "qryCars_Sale", acFormatXLSX, sFilename, Autostart:=False

 

 

Option Compare Database

Option Explicit On

 

 

'-------< Buttons >------------

Private Sub BtnExport_Click()

    DoCmd.OutputTo acOutputQuery, "qryCars_Sale", acFormatXLSX, , True

End Sub

 

 

Private Sub btnExport_to_Filename_Click()

    Dim sFilename As String

    sFilename = "C:\_Daten\Desktop\Demo\Access\2018-01-02 Access Export Query\Output_Results.xlsx"

    DoCmd.OutputTo acOutputQuery, "qryCars_Sale", acFormatXLSX, sFilename, Autostart:=False

End Sub

'-------</ Buttons >------------

 

 

Private Sub optSelect_AfterUpdate()

    subform_Data.Requery

End Sub

 

 

Code under Visual Basic for Applications vba

Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de