1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Private Sub btnExportpdf0_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strChemin As String
Dim strFichier As String
Dim strSql As String
Const strReportName = "nom de l etat" ' mettre à jour le nom de l'état
strChemin = Application.CurrentProject.Path & "\archives_factures\Commissions\"
strSql = "SELECT DISTINCT num_com, date_com, etc." _
& " FROM tbl_com"
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset)
If rst.RecordCount = 0 Then Exit Sub
rst.MoveLast
rst.MoveFirst
Do Until rst.EOF
strFichier = Format([date_com], "yyyy-mm") & " - Factures commissions " & Format([date_com], "mmmm yyyy")
strFichier = strFichier & " - " & rst("num_com") & ".pdf"
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strChemin & strFichier
DoCmd.Close acReport, strReportName
DoEvents
rst.MoveNext
Loop
Application.FollowHyperlink strChemin 'ouvre le dossier destination *.pdf
End Sub |
Partager