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
|
Private Sub MàJ_CpteRendu_Click()
Dim Mabase As Database
Dim frm As Form
Dim Qrt As QueryDef
Dim SqlUpdate As String, SqlUpdate1 As String
Dim Msg, Style, Title, Reponse, MyString
Dim Maj As String, Client As String
Set Mabase = CurrentDb
Set Qrt = Mabase.CreateQueryDef("", SqlUpdate)
Set frm = Me.Sfrm_RegrOutlook.Form
'A conserver (syntaxe qui permet d'atteindre le controle d'un sous formulaire)
Maj = Forms![Frm_Prospects]![Sfrm_RegrOutlook].Form![Maj_CpteRendu]
Client = Forms![Frm_Prospects]![Sfrm_RegrOutlook].Form![CodeClient]
Msg = "Souhaitez-vous continuer?" ' Définit le message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Définit les boutons.
Title = "Mise à jour de la Table TBL_RegrOutlook " ' Définit le titre.
Reponse = MsgBox(Msg, Style, Title) ' Affiche le message.
If Reponse = vbNo Then ' L'utilisateur a choisi Non.
MyString = "Non" ' Effectue une action.
Exit Sub
Else
MyString = "Oui" ' L'utilisateur a choisi Oui. Effectue une action.'Date() AS [Date]
SqlUpdate = "INSERT INTO Tbl_CpteRendu ( Code_Client, Commercial, [Date], CpteRendu )"
SqlUpdate = SqlUpdate & "SELECT Tbl_TempRegrOutlook.CodeClient, Tbl_TempRegrOutlook.Commercial, "
SqlUpdate = SqlUpdate & " Tbl_TempRegrOutlook.Date, Tbl_TempRegrOutlook.Message "
SqlUpdate = SqlUpdate & " FROM Tbl_TempRegrOutlook WHERE ((Tbl_TempRegrOutlook.CodeClient) Is Not Null)"
SqlUpdate1 = " UPDATE Tbl_RegrOutlook SET Tbl_RegrOutlook.CodeClient = " & "'" & Client & "'" & ","
SqlUpdate1 = SqlUpdate1 & "Tbl_RegrOutlook.Maj_CpteRendu = " & "'" & Maj & "'" & ";"
Debug.Print SqlUpdate1
Mabase.Execute SqlUpdate, dbFailOnError
Mabase.Execute SqlUpdate1, dbFailOnError
MsgBox "Vous avez ajouté " & Mabase.RecordsAffected & " nouveaux Compte-Rendu."
End If
End Sub |
Partager