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
| 'Ajout d'une tâche dans la table Taches
Public Sub ajoutTache()
' Connexion à la BD
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
Dim strCnn As String
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\WorStat\WorStatData.mdb;"
cnn.Open strCnn
'Insertion d'une tâche
Dim cmdInsert As New ADODB.Command
Dim strInsert As String
Dim ID As Long
Dim etat As Boolean
ID = genereIDTache(cnn)
etat = False
strInsert = "INSERT INTO Taches (Numero,Num_Demande,IDTache,DateExecution,EstTerminee) VALUES (" & ID & "," & Screen.ActiveForm!ztIDDemande & "," & ID & ",#" & Format(Screen.ActiveForm!ztDateDebutTraitement, "mm/dd/yyyy") & "#," & etat & ")"
cnn.BeginTrans
With cmdInsert
.ActiveConnection = cnn
.CommandText = strInsert
.CommandType = adCmdText
.Execute
End With
cnn.CommitTrans
cnn.Close
Set cnn = Nothing
End Sub |
Partager