no duplicate records if

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
 
R

Rob Oldfield

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top