salut les amis j'ai un pb je vous explique
j'ai deux table collaborateur et planning dont la table collaborateur contient
matricule comme clé primaire et planning matpla clé primaire et clé etrangére sur matricule de la table collaborateur, donc je veux inérer dans la table planning un enregistrement mais ci un collaborateur ne trouve pas dans la table collaborateur il doit m'afficher un message qu'il n'existe pas exemple:
table collaborateur :
Matricule : 341
Nom : alex
table planning
matpla:341
planning :10h
ajout c'est ok mais si
matpla:200
planning:10h
collab n'existe pas car la matricule 200 ne se trouve pas dans la table collaborateur j'ai mis le code suivant pour l'insertion mais j'ai pas trouver comment testersi le collab existe dans la table collaborateur avant l'insertion de son planning dans la table planning:
If txtmatch.Text = "" Or txtplact.Text = "" Or txtpladem.Text = "" Or IsDate(txtdepo.Text) = False Then
x = MsgBox("Vous devez vérifier les champs", vbInformation, "Hotline Technique")
Exit Sub
End If
If txtmatch.Text <> "" And txtplact.Text <> "" And txtpladem.Text <> "" And txtdepo.Text <> "" Then
Dim usex As Boolean
usex = False
Call maconnexion
rs.ActiveConnection = c
rs.Open "select MATPLA,ACTUEL,DEMANDE,DATE_DEPOT from PLANNING"
Do While Not rs.EOF
If rs.Fields(0).Value = txtmatch.Text And rs.Fields(1).Value = txtplact.Text And rs.Fields(2).Value = txtpladem.Text And rs.Fields(3).Value = txtdepo.Text Then
usex = True
End If
rs.MoveNext
Loop
If usex = True Then
x = MsgBox("Cet enregistrement existe déjà", vbInformation)
Else
c.Execute " insert into PLANNING values ('" & txtmatch.Text & "' ,'" & txtnomch.Text & "','" & txtplact.Text & "','" & txtpladem.Text & "','" & txtdepo.Text & "','" & txtsem.Text & "','" & txtcau.Text & "')"
c.Execute "commit"
x = MsgBox("sauvegarde effectué ", vbInformation)
End If
End If