Bonjour à tous,
je cherche à améliorer le code suivant, destiné à reporter une facture dans un email. C'est une application Access.
Code :
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 50 51 52 53 54 55 56 57 58 59 60 61
|
Public Function DescriptionTxt() As String
Dim Txt As String
Dim RS As Recordset
Dim TotalVol As Long
If IsNull(Me.IDCmd) Then
DescriptionTxt = ""
Exit Function
End If
Txt = Format(Me.IDEta.Column(2), ">") & vbCrLf & vbCrLf
Txt = Txt & "Date : " & Format(Me.DateCmd, "dddd d mmmm yyyy") & vbCrLf
Txt = Txt & "N/Réf. : " & Format(Me.NRef, "00-0000") & vbCrLf
If Not IsNull(Me.NumPiece) Then Txt = Txt & "Pièce : " & Me.NumPiece & vbCrLf
If Not IsNull(Me.VRef) Then Txt = Txt & "V/Réf. : " & Me.VRef & vbCrLf
If Not IsNull(Me.VAT) Then Txt = Txt & "V/VAT : " & Me.VAT & vbCrLf
Txt = Txt & vbCrLf & "________________________________________________________________" & vbCrLf & vbCrLf
Txt = Txt & "ADRESSE" & vbCrLf & vbCrLf
Txt = Txt & Me.Adresse & vbCrLf
Txt = Txt & vbCrLf & "________________________________________________________________" & vbCrLf & vbCrLf
Txt = Txt & "DETAIL DE LA COMMANDE" & vbCrLf
Set RS = CurrentDb.OpenRecordset("SELECT Detail.IDDet, IIf(IsNull([IDCtg]),[IDLiv],[Categorie] & "" - "" & [Num]) AS Ref, Detail.Designation, Detail.NbVol, Detail.Prix FROM Detail LEFT JOIN Categorie ON Detail.IDCtg = Categorie.IDCat WHERE Detail.IDCmd = " & Me.IDCmd & " ORDER BY Detail.IDDet")
TotalVol = 0
Do While Not RS.EOF
Txt = Txt & vbCrLf
If Not IsNull(RS!Ref) Then Txt = Txt & RS!Ref & " : "
Txt = Txt & RS!Designation & vbCrLf
Txt = Txt & RS!NbVol & " vol. - " & Format(RS!Prix, "# ##0.00") & " EUR" & vbCrLf
TotalVol = TotalVol + RS!NbVol
RS.MoveNext
Loop
RS.Close
Txt = Txt & vbCrLf & "________________________________________________________________" & vbCrLf & vbCrLf
Txt = Txt & "RECAPITULATIF" & vbCrLf & vbCrLf
Txt = Txt & TotalVol & " vol. - " & Format(Me.SousTotalAvant, "# ##0.00") & " EUR" & vbCrLf
If Me.Remise <> 0 Then
Txt = Txt & vbCrLf & "Remise : " & Format(Me.Remise, "# ##0.00") & " EUR" & vbCrLf
Txt = Txt & vbCrLf & "______________________________________" & vbCrLf & vbCrLf
Txt = Txt & "Sous-total : " & Format(Me.SousTotalApres, "# ##0.00") & " EUR" & vbCrLf
End If
Txt = Txt & vbCrLf & "Port et assurance : " & Format(Me.Port, "# ##0.00") & " EUR" & vbCrLf
Txt = Txt & vbCrLf & "______________________________________" & vbCrLf & vbCrLf
Txt = Txt & Format(Me.SousTotalFinal, "# ##0.00") & " EUR" & vbCrLf
If (Me.Total + Me.Acompte - Me.TVA - Me.Port - Me.SousTotalApres) >= -1 Then
Txt = Txt & vbCrLf & "TVA 4% : " & Format(Me.TotalTVA, "# ##0.00") & " EUR" & vbCrLf
End If
Txt = Txt & vbCrLf & "______________________________________" & vbCrLf & vbCrLf
Txt = Txt & "TOTAL de votre commande : " & Format(Me.Total + Me.Acompte, "# ##0.00") & " EUR" & vbCrLf
If Me.TotalTVA > 0 Then
Txt = Txt & vbCrLf & "dont TVA : " & Format(Me.TotalTVA, "# ##0.00") & " EUR" & vbCrLf
End If
If Me.Acompte <> 0 Then
Txt = Txt & vbCrLf & "Acompte déjà versé : " & Format(Me.Acompte, "# ##0.00") & " EUR" & vbCrLf
Txt = Txt & "SOLDE restant à payer : " & Format(Me.Total, "# ##0.00") & " EUR" & vbCrLf
End If
Txt = Txt & vbCrLf & vbCrLf & vbCrLf & Me.Notes
DescriptionTxt = Txt
End Function |
Ce que je voudrais c'est que l'adresse email du destinaire soit insérée à sa place, à partir du champ Me.Email, dans l'email généré par la fonction. Ainsi on n'aurait plus qu'à envoyer l'email alors qu'actuellement il faut d'abord aller repêcher l'adresse email dans la fiche du client.
Merci d'avance pour vos suggestions