G
Guest
Hi all.
I got some very valuable assistance from a couple guys in this group on
DLOOKUP. I'm trying to setup a 'yes/no' message box that is based off the
DLOOKUP and will come up once DLOOKUP tests and verifies a duplicate record.
I've got code for that, and everything works, except the end result on a
"yes" response puts you back to record #1 instead of to the then matching
record; I want a "yes" response to take me to the matching record found.
Here's my code, any thoughts?
To assist, the following fields have the following formats:
[Reseller Account Number] Text
[End User Name] Text
[Amount] Currency
And [dup PO check] is a table name.
Thanks a million guys! This will save alot of headaches!
________________________________________
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim varDUPPO As Variant
If Me.NewRecord Then
varDUPPO = DLookup("[Reseller Account Number]", "[dup PO check]",
"[Reseller Account Number] = '" & Me![Reseller Account Number] & "' AND [End
User Name] = '" & Me![End User Name] & "' AND [Amount] = " & Me![Amount])
If Not IsNull(varDUPPO) Then
If MsgBox("This record already exists." & _
"Cancel this new entry and review the previous
entry? If NO, please put brief reason for duplicate in notes box.", _
vbQuestion + vbYesNo, _
"Duplicate Entry Found") _
= vbYes _
Then
Cancel = True
Me.Undo
Me.Recordset.FindFirst "[Reseller PO#]='" & varDUPPO & "'"
End If
End If
End If
End Sub
_________________________________________
bluezcruizer
I got some very valuable assistance from a couple guys in this group on
DLOOKUP. I'm trying to setup a 'yes/no' message box that is based off the
DLOOKUP and will come up once DLOOKUP tests and verifies a duplicate record.
I've got code for that, and everything works, except the end result on a
"yes" response puts you back to record #1 instead of to the then matching
record; I want a "yes" response to take me to the matching record found.
Here's my code, any thoughts?
To assist, the following fields have the following formats:
[Reseller Account Number] Text
[End User Name] Text
[Amount] Currency
And [dup PO check] is a table name.
Thanks a million guys! This will save alot of headaches!
________________________________________
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim varDUPPO As Variant
If Me.NewRecord Then
varDUPPO = DLookup("[Reseller Account Number]", "[dup PO check]",
"[Reseller Account Number] = '" & Me![Reseller Account Number] & "' AND [End
User Name] = '" & Me![End User Name] & "' AND [Amount] = " & Me![Amount])
If Not IsNull(varDUPPO) Then
If MsgBox("This record already exists." & _
"Cancel this new entry and review the previous
entry? If NO, please put brief reason for duplicate in notes box.", _
vbQuestion + vbYesNo, _
"Duplicate Entry Found") _
= vbYes _
Then
Cancel = True
Me.Undo
Me.Recordset.FindFirst "[Reseller PO#]='" & varDUPPO & "'"
End If
End If
End If
End Sub
_________________________________________
bluezcruizer