trap duplicate number entry

  • Thread starter Thread starter Perry Kew
  • Start date Start date
P

Perry Kew

I have the following which works on a text field. However,
it doesn't seem to work on a number field! The code below
was placed on a field called NumField in the AfterUpdate
property.

The field is not a Primary Key field and duplicates are
allowed in special cases.

If DCount("*", "tblData", "[NumField] ='" & Me.NumField
& "'") > 0 Then
MsgBox("This is a duplicate entry!",, "Duplicate")
DoCmd.CancelEvent
End if

Please help me with the above bit of faulty code. Thank
you.

--Perry
 
you don't need the single quotes on number fields.

If DCount("*", "tblData", "[NumField] =" & Me.NumField ) > 0 Then
 
Thank you very much for your help!
-----Original Message-----
you don't need the single quotes on number fields.

If DCount("*", "tblData", "[NumField] =" & Me.NumField )
0 Then


I have the following which works on a text field. However,
it doesn't seem to work on a number field! The code below
was placed on a field called NumField in the AfterUpdate
property.

The field is not a Primary Key field and duplicates are
allowed in special cases.

If DCount("*", "tblData", "[NumField] ='" & Me.NumField
& "'") > 0 Then
MsgBox("This is a duplicate entry!",, "Duplicate")
DoCmd.CancelEvent
End if

Please help me with the above bit of faulty code. Thank
you.

--Perry


.
 
Back
Top