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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Private Sub CmndVal_Click()
'initialize variables
On Error Resume Next
Dim filtre As String
Dim i As Integer
Dim j As Integer
filtre = ""
For i = 0 To Me.ListEmp.ListCount - 1
If Me.ListEmp.Selected(i) Then
If Not IsNull(Me.Cbodep.Value) Then
filtre = "([Department]='" & Me.Cbodep.Value & "')"
End If
If Not IsNull(Me.Datedeb) And Me.Datedeb <> "" And Not IsNull(Me.Datefin) And Me.Datefin <> "" Then
filtre = filtre & " AND Clng([LogDate]) BETWEEN " & CLng(Me.Datedeb) & " AND " & CLng(Me.Datefin) & ""
End If
filtre = filtre & " AND [Nom]='" & Me.ListEmp.Column(0, i) & "'"
filtre = filtre & " AND [PreNom]='" & Me.ListEmp.Column(1, i) & "'"
j = j + 1
Select Case Me.CadrExport.Value
Case 1
If Me.checkRR.Value = True Then
DoCmd.OpenReport "Rapport Retards", acViewReport, , filtre
États![Rapport Retards]![Texte37] = Me.ListEmp.Column(0, i) & " " & Me.ListEmp.Column(1, i)
DoCmd.PrintOut , , , , j
DoCmd.Close acReport, "Rapport Retards"
End If
Case 2
strChemin = "C:\EXPORT" & Format(Now, "ddmmyyyy hhnn") & "\ "
MkDir (strChemin)
If Me.checkRR.Value = True Then
DoCmd.OpenReport "Rapport Retards", acViewReport, , filtre
États![Rapport Retards]![Texte37] = Me.ListEmp.Column(0, i) & " " & Me.ListEmp.Column(1, i)
DoCmd.OutputTo acOutputReport, "Rapport Retards", acFormatPDF, strChemin & "RapportRetards" & Me.ListEmp.Column(0, i) & "_" & Me.ListEmp.Column(1, i) & ".pdf"
DoCmd.Close acReport, "Rapport Retards"
End If
End Select
End If
Next i
End Sub |
Partager