You've got two If statements, but only one End If. (Sorry I missed that
before)
Private Sub OEM_NUMBER_BeforeUpdate(Cancel As Integer)
If DCount("[OEM_NUMBER]", _
"[ATLANTIS]", _
"[OEM_NUMBER] = '" & Me.OEM_NUMBER & "'") 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
or
Private Sub OEM_NUMBER_BeforeUpdate(Cancel As Integer)
If DCount("[OEM_NUMBER]", _
"[ATLANTIS]", _
"[OEM_NUMBER] = '" & Me.OEM_NUMBER & "'") Then
Cancel = ("This OEM already exists!!!" & vbcrlf & _
"Add it anyway?", vbYesNo) = vbNo
End If
End Sub
--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)
chynewalker said:
I fixed the word wrap, but it still get the error 'MB91443-20600"compile
error: block if without end if"
Douglas J. Steele said:
Don't know whether you've got a problem with word-wrap or not.
For the line
If MsgBox("This OEM already exists!!!" & vbcrlf & "Add it anyway?",
vbYesNo)
= vbNo Then
everything between "If" and "Then" should be on a single line.
--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)
chynewalker said:
Private Sub OEM_NUMBER_BeforeUpdate(Cancel As Integer)
If DCount("[OEM_NUMBER]", _
"[ATLANTIS]", _
"[OEM_NUMBER] = '" & Me.OEM_NUMBER & "'") Then
If MsgBox("This OEM already exists!!!" & vbcrlf & "Add it anyway?",
vbYesNo)
= vbNo Then
Cancel = True
Else 'Do nothing
End If
End Sub
I just get an compile error when i use this
:
chynewalker wrote:
I created this code to pop a box up that will let me know when i have
a
duplicate number, however, I want to still be able to write a
duplicate
entry.
Private Sub OEM_NUMBER_BeforeUpdate(Cancel As Integer)
If DCount("[OEM_NUMBER]", _
"[ATLANTIS]", _
"[OEM_NUMBER] = '" & Me.OEM_NUMBER & "'") Then
MsgBox "This oem number already exists!!!"
Cancel = True
Else 'Do nothing
End If
End Sub
You need to put the Cancel = True inside another If statement.
e.g.
If MsgBox("This OEM already exists!!!" & vbcrlf & "Add it anyway?",
vbYesNo)
= vbNo Then
Cancel = True
Else...
--
.
.