I searched the forum here and found what I thought was just the answer I was looking for in an earlier thread. However when I try and paste the code from the post I keep getting a compile error "Expected seprator or )".
Being the nooby that I am I have tried putting () around just about everything that I can think of but it still doesn't seem to like it
.
All I am trying to do and I thought it would be simple, is to check and make sure the serial number that is being entered in the text box does not already exist in the table. Occasionally the user may have to input a list of say 8-10 serial numbers and I want to be able to warn them if they enter a duplicate before completing the entire form. The field is set to required, indexed - no duplicates and basically I am trying to avoid the generic 3022 message that most users do not understand and replace it with one of my own.
Can anyone tell me what I am missing here or can someone possibly suggest a better solution?
I have attached the stripped down database in case my explanation is not clear enough.
Any help would be greatly appreciated.
Richard
Being the nooby that I am I have tried putting () around just about everything that I can think of but it still doesn't seem to like it
All I am trying to do and I thought it would be simple, is to check and make sure the serial number that is being entered in the text box does not already exist in the table. Occasionally the user may have to input a list of say 8-10 serial numbers and I want to be able to warn them if they enter a duplicate before completing the entire form. The field is set to required, indexed - no duplicates and basically I am trying to avoid the generic 3022 message that most users do not understand and replace it with one of my own.
Code:
Private Sub txtserialnumber_BeforeUpdate(Cancel As Integer)
If DCount("[serialnumber]","[SerialNumber]","[serialnumber]" = "& Me.[[COLOR=black]serialnumber] = 0 )[/COLOR] [COLOR=blue]---error appears here---[/COLOR]
Then
MsgBox "The Serial Number [" & Me.[txtserialnumber] & "] is a duplicate."
Cancel = True
End If
End Sub
Can anyone tell me what I am missing here or can someone possibly suggest a better solution?
I have attached the stripped down database in case my explanation is not clear enough.
Any help would be greatly appreciated.
Richard