trap duplicate number entry

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
 
R

Rodrigo

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

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

Perry

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


.
 

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