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
|
Private Sub MàJ_CpteRendu_Click()
Dim Mabase As Database
Dim Qrt As QueryDef
Dim SqlUpdate As String
Dim Msg, Style, Title, Reponse, MyString
Set Mabase = CurrentDb
Set Qrt = Mabase.CreateQueryDef("", SqlUpdate)
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_RegrOutlook.CodeClient, Tbl_RegrOutlook.Commercial, "
SqlUpdate = SqlUpdate & " Tbl_RegrOutlook.Date, Tbl_RegrOutlook.Message "
SqlUpdate = SqlUpdate & " FROM Tbl_RegrOutlook "
SqlUpdate = SqlUpdate & "WHERE (((Tbl_RegrOutlook.Commercial) Is Not Null) AND ((Tbl_RegrOutlook.Maj_CpteRendu)=True));"
Mabase.Execute SqlUpdate, dbFailOnError
MsgBox "Vous avez ajouté " & Mabase.RecordsAffected & " nouveaux Compte-Rendu."
End If
End Sub |
Partager