hello everyone,
I want to try something new in my database.
Well, I have a working VBA code for export my selected datas from database to excel.
But now I would like to do that again with pdf document.
The source will be the same like for excel, but I want to export everything to a report called "Položky skladu".
It is existing report in my database and it´s source is a query called "D_Položky skladu".
Could somebody help me with this?
VBA code for Excel export:
Private Sub Export_XLS_Click()
Dim MyDB As Database
Dim qdfTemp As QueryDef
Dim xSql As String, xPortFileName As String
xSql = Me.RecordSource
Set MyDB = CurrentDb
On Error GoTo xErr
With MyDB
xPortFileName = "Excel_Položky skladu"
Set qdfTemp = .CreateQueryDef(xPortFileName, xSql)
DoCmd.OutputTo acOutputQuery, qdfTemp.Name, , , -1, , , acExportQualityPrint
.QueryDefs.Delete xPortFileName
Exit_Export_XLS:
Exit Sub
xErr:
If Err.Number = 2501 Then
MsgBox "Export do *.xls zrušený používateľom", vbInformation, "INFO"
Else
MsgBox Error$
.QueryDefs.Delete xPortFileName
End If
End With
Resume Exit_Export_XLS
End Sub