Access 2003 duplicate record in subform want to autodelete and let user know

I have a subform on a form. There are two fields that show on the form.

The first field is a Main Account number and what this "Main" account number listed only once. If the user types in this main account number again on the subform i want a pop up to tell them this is a duplicate and delete it.
Who is Participating?
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
yes, that can be done

me.undo  'will cancel the entered items in the form

to go to the previous record, you need more vba codes.
* you can use the FindFirst command to goto to the previous record

PdetersAuthor Commented:
I want to exit the field without saving
Rey Obrero (Capricorn1)Commented:
try this in the beforeupdate event of the control for main account (txtAccount in this code)

private sub txtaccount_beforeUpdate(cancel as integer)

if dcount("*","tablesubform","accountnumber=" & me.txtaccount)>0 then
  msgbox "duplicate account"
end if

end sub
PdetersAuthor Commented:
Is there a way to not save the record and jump back to the previous record in the subform?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.