Link to home
Start Free TrialLog in
Avatar of Pdeters
Pdeters

asked on

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.
Avatar of Pdeters
Pdeters

ASKER

I want to exit the field without saving
Avatar of Rey Obrero (Capricorn1)
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
Avatar of Pdeters

ASKER

Is there a way to not save the record and jump back to the previous record in the subform?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial