duplicate prevention in form

C

chynewalker

Hi,

I have a slight problem with my code, It is to prevent a number from being
entered multiple times, but occasionally i want a duplicate.
So i wrote this code to try to find the duplicate and prompt me to allow it
or not.
however it says every number exists already. what wrong?? help

thanks

john
Private Sub OEM___BeforeUpdate(Cancel As Integer)

If DCount("[OEM___]", _
"[drawings1]", _
"[OEM___] = '" & Me.OEM___ & "'") Then
If MsgBox("This OEM already exists!!!" & vbCrLf & "Add it anyway?", vbYesNo)
= vbNo Then
Cancel = True
Else 'Do nothing
End If
End If
End Sub
 
C

chynewalker

i am still not able to get it to function using both methods.
I understand the names are kinda dumb but i didnt design this so I dont have
a say.

I think the problem stems from the fact that The control source is really
named OEM #

That is with a space between the oem and #. , Access didnt like that so i
replaced the space and # with the underscores.
 
D

Daryl S

Chynewalker -

If your control source is really named OEM #, then change that control name
to OEM___ to match what is in your code.
 

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