no duplicate records if

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an error-DB for machines. I don’t want users to insert duplicates if
the error isn’t solved. Therefor the code has to look in the field ‘Datum
gereed’ (a date field). If the error is solved there will be a date in this
field.

Who can help me to rebuild the code?

Private Sub Objectnr_BeforeUpdate(Cancel As Integer)
If (Not IsNull(DLookup("[Objectnr]", _
"Storingen", "[Objectnr] ='" _
& Me!Objectnr & "'"))) Then
MsgBox "Storing is reeds ingevoerd, controleer de status."
Cancel = True
Me!Objectnr.Undo
End If
End Sub
 
I don't get exactly what you mean. The code you've supplied is the same
thing, but for a text field, and you just need to know how to make it work
for a date? If that is the case then you'll just need to do much the same
thing, but with the # character instead of the '. Something like..

If (Not IsNull(DLookup("[PKField]", _
"Storingen", "[Datum gereed] =#" _
& Me![Datum gereed] & "#"))) Then

Without sitting down and trying it, I can't remember if you might need a
cstr function in there to turn Me![Datum gereed] into text.
 
Back
Top