Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to prevent Duplicates

Status
Not open for further replies.

puppygirl3939

Technical User
Sep 15, 2003
21
0
0
US
I have a main form containing the companyID and a subform to enter the counties where I am sending the company info. The subform contains a combo box with all of my counties. How can I prevent the user from selecting the county twice?

Example
Main Form - CompanyID = 25
Sub Form - Counties Referred
Orange County
Seminole County
Martin County
If the user selects Orange County again it should give them a message "You have selected this county previously. You can not enter the same county twice". The county table will contain the companyID 3 times which is okay but it should not have the countyID repeated.

Also if I can have a check box called Statewide. If Statewide = Yes then it should automatically enter 67 counties for that company ID. The counties table will have the companyID repeated 67 times but each record will contain the individual county. Please help!
 
I would allow the user to go hog wild with the subform. Then, I would fix the problem after the fact. Here are two ways to fix the problem:

1) create a macro that runs a delete query which cleans things up. Run it when the form closes.

2) When you do reports, use grouping queries on the data, so that duplicate records "drop out".

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top