Hi Guys,
New programmer here so please be kind on my terrible errors!
I'm trying to prevent duplicate data being entered into a given database and need some help. I've wrote the following code in the after update event of the "date_vl" control, which is after the input of the product control.
Dim criteria As String
critère = _
"Tbl_VL.product = " & Me.product & " " & _
"AND Tbl_VL.vl_date = " & Me.vl_date
If DCount("VL_id", "Tbl_VL", critère) > 0 Then
MsgBox "Il y existe déjà un enregistrement pour ce produit et la date associée."
Me.Undo
End If
End Sub
The idea is that the code references the Tbl_
Dim criteria As String
criteria = _
"Tbl_VL.produit = " & Me.produit & " " & _
"AND Tbl_VL.vl_date = " & Me.vl_date
If DCount("VL_id", "Tbl_VL", criteria) > 0 Then
MsgBox "Il existe déjà un enregistrement pour ce produit et la date associée."
Me.Undo
End If
End Sub
The idea is that if the product and the associated date exist in table "Tbl_VL", then a message box will appear. Yet when I enter data on purpose that should trigger the coding, nothing happens.
Any help would be greatly appreciated.
MOR
New programmer here so please be kind on my terrible errors!
I'm trying to prevent duplicate data being entered into a given database and need some help. I've wrote the following code in the after update event of the "date_vl" control, which is after the input of the product control.
Dim criteria As String
critère = _
"Tbl_VL.product = " & Me.product & " " & _
"AND Tbl_VL.vl_date = " & Me.vl_date
If DCount("VL_id", "Tbl_VL", critère) > 0 Then
MsgBox "Il y existe déjà un enregistrement pour ce produit et la date associée."
Me.Undo
End If
End Sub
The idea is that the code references the Tbl_
Dim criteria As String
criteria = _
"Tbl_VL.produit = " & Me.produit & " " & _
"AND Tbl_VL.vl_date = " & Me.vl_date
If DCount("VL_id", "Tbl_VL", criteria) > 0 Then
MsgBox "Il existe déjà un enregistrement pour ce produit et la date associée."
Me.Undo
End If
End Sub
The idea is that if the product and the associated date exist in table "Tbl_VL", then a message box will appear. Yet when I enter data on purpose that should trigger the coding, nothing happens.
Any help would be greatly appreciated.
MOR