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
|
Private Function Trt_Existe(Code_Oaci As String) As Boolean
Dim RS As Recordset
On Error GoTo Err_Num
WCode_OACI = Trim(UCase(Code_Oaci))
WRequete = "Select * from COM where COM.C_OACI = '" & WCode_OACI & "'"
Set RS = CurrentDb.OpenRecordset(WRequete, 2)
With RS
.OpenRecordset
If .RecordCount > 0 Then
Trt_Existe = True
End If
.Close
End With
Sortie_Num:
Set RS = Nothing
Exit Function
Err_Num:
Trt_Existe = False
Resume Sortie_Num
End Function
Private Sub C_OACI_BeforeUpdate(Cancel As Integer)
If Trt_Existe(C_OACI.Value) Then
MsgBox "Ce code OACI existe déjà dans la table."
Cancel = True
C_OACI.SetFocus
End If
End Sub |
Partager