There is no actual error - the message pops up - but it pops up for any entry.
Yes MEMBERNO is the control on the form which is straight from the table, no
query.
Private Sub MEMBERNO_BeforeUpdate(Cancel As Integer)
If Me.MEMBERNO = "H23917176" Or Me.MEMBERNO = "H39592261" Then
Cancel = True
Else
MsgBox "** Contact the fraud dept. ASAP **"
Exit Sub
End If
End Sub
Okay, I see what you are saying. The code is doing exactly what you are
telling it to do. (that's what I hate about computers)
Private Sub MEMBERNO_BeforeUpdate(Cancel As Integer)
If Me.MEMBERNO = "H23917176" Or Me.MEMBERNO = "H39592261" Then
Cancel = True
Else
MsgBox "** Contact the fraud dept. ASAP **"
Exit Sub
End If
End Sub
As written, the code will throw the message box for every member number
except the two you have in the code. If you want the message to show only
for those 2 codes, it needs to be this way:
Private Sub MEMBERNO_BeforeUpdate(Cancel As Integer)
If Me.MEMBERNO = "H23917176" Or Me.MEMBERNO = "H39592261" Then
Cancel = True
MsgBox "** Contact the fraud dept. ASAP **"
End If
End Sub
However, I would not hard code something like member numbers. I would have
a field in the member table that would tell us to flag this as a fraud alert.
Then if you have to add or remove member numbers, you don't have to change
the code, you only need to change the flag in the member record:
Private Sub MEMBERNO_BeforeUpdate(Cancel As Integer)
If Nz(DLookup("[FRAUD_ALERT]", "tblMember","[MEMBERNO] = '" &
Me.MEMBERNO & "'",0)) = True Then
Cancel = True
MsgBox "** Contact the fraud dept. ASAP **"
End If
End Sub

Signature
Dave Hargis, Microsoft Access MVP
> There is no actual error - the message pops up - but it pops up for any entry.
> Yes MEMBERNO is the control on the form which is straight from the table, no
> query.
Private Sub MEMBERNO_BeforeUpdate(Cancel As Integer)
> If Me.MEMBERNO = "H23917176" Or Me.MEMBERNO = "H39592261" Then
> Cancel = True
[quoted text clipped - 59 lines]
> > > > > > > > > > End If
> > > > > > > > > > End Sub
Dan @BCBS - 26 Jun 2007 22:46 GMT
Words or Money could not express my thankfullness..
So I'll just say it - Thank you...
> Okay, I see what you are saying. The code is doing exactly what you are
> telling it to do. (that's what I hate about computers)
[quoted text clipped - 100 lines]
> > > > > > > > > > > End If
> > > > > > > > > > > End Sub
Klatuu - 26 Jun 2007 22:49 GMT
I'd rather have the money :)
You are welcome, sorry about my initial confusion.

Signature
Dave Hargis, Microsoft Access MVP
> Words or Money could not express my thankfullness..
> So I'll just say it - Thank you...
[quoted text clipped - 103 lines]
> > > > > > > > > > > > End If
> > > > > > > > > > > > End Sub