We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

Pdeters
Pdeters asked
on
Medium Priority
247 Views
Last Modified: 2012-05-11
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.
Comment
Watch Question

Author

Commented:
I want to exit the field without saving
CERTIFIED EXPERT
Top Expert 2016

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"
  cancel=true
 
end if


end sub

Author

Commented:
Is there a way to not save the record and jump back to the previous record in the subform?
CERTIFIED EXPERT
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.