Bonjour à tous,
J'ai un souci que j'arrive pas a résoudre.
Voila le code :
Si quelqu'un pouvais m'aider, sa serais super cool. Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Dim rst As DAO.Recordset, rst2 As DAO.Recordset Dim frm As Form, ctl As Control, txtNumeroEmploye As Control Dim varElt As Variant Dim Sql As String Set frm = Forms!frmPlanningEmploye Set ctl = frm!lstPlanningsDisponibles Set txtNumeroEmploye = frm!txtNumeroEmploye DoCmd.SetWarnings False For Each varElt In ctl.ItemsSelected Set rst = CurrentDb.OpenRecordset("SELECT intTypePlanning FROM tblPlanning WHERE intNumeroPlanning = " & ctl.ItemData(varElt) & " ") Sql = "SELECT intTypePlanning FROM tblPlanning WHERE intNumeroPlanning = '" & ctl.ItemData(varElt) & "' AND intNumeroEmploye = '" & [txtNumeroEmploye] & "' AND intTypePlanning = " & rst!intTypePlanning Set rst2 = CurrentDb.OpenRecordset(Sql, 2) If rst2.RecordCount <> 0 Then MsgBox "Attention l'employé dispose déjà de ce type de planning.", vbExclamation, "Impossible d'ajouter ce planning" Else DoCmd.RunSQL "INSERT INTO tblPlanningEmploye " & _ "SELECT tblPlanning.intNumeroPlanning, tblPlanning.intTypePlanning, " & txtNumeroEmploye & " as intNumeroEmploye " & _ "FROM tblPlanning " & _ "WHERE tblPlanning.intNumeroPlanning = " & ctl.ItemData(varElt) & ";" End If Next varElt![]()
Partager