• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

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.
0
Pdeters
Asked:
Pdeters
  • 2
  • 2
1 Solution
 
PdetersAuthor Commented:
I want to exit the field without saving
0
 
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"
  cancel=true
 
end if


end sub
0
 
PdetersAuthor Commented:
Is there a way to not save the record and jump back to the previous record in the subform?
0
 
Rey Obrero (Capricorn1)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


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now