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
| Private Sub Imprim_contrat_Click()
Dim RST As DAO.Recordset
Me.Refresh
Set RST = Me.F_Contrats_Liste_SF.Form.RecordsetClone
With RST
.MoveFirst
Do While Not .EOF
If .Fields("selection") = True Then
DoCmd.OpenReport "E_Contrat_par_N°_Contrat_2022", acViewPreview, , "N°_Contrat = " & .Fields("N°_Contrat")
Dim MesVariables As String '<= Déclaration pour nommer le fichier pdf
a = .Fields("nom")
b = "_["
c = .Fields("N°_Société")
d = "]_("
e = .Fields("N°_Contrat")
f = ")_"
g = .Fields("Enseigne")
h = "_"
i = .Fields("date_anim")
j = "_Sem "
k = .Fields("Num_Sem")
l = "_"
m = .Fields("Nature_Contrat")
n = "_"
o = .Fields("Envoi_des_contrats")
Dim sFileName As String 'construction du nom du fichier
strEnviron = CreateObject("WScript.Shell").specialfolders("Desktop") ' envoi le fichier sur le bureau
strFolder = "\A envoyer\" 'plus prcis dans le fichier a envoyer
strFilePath = strEnviron & strFolder
sFileName = strFilePath & " " & a & b & c & d & e & f & g & h & i & j & k & l & m & n & o & ".pdf" '<= Renomme le fichier selon les variables
DoCmd.OutputTo acOutputReport, "E_Contrat_par_N°_Contrat_2022", "pdf", sFileName
DoCmd.Close acReport, "E_Contrat_par_N°_Contrat_2022", acSaveNo
End If
.MoveNext
Loop
End With
End Sub |