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 strongm 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 a Record From Being Saved

Status
Not open for further replies.

referee

Programmer
Jun 25, 2001
3
IL
I have 2 fields in a table. the first that is a Team(Number) and the second field is Round(Number). we're talking of basketball btw.
i would like to prevent a save of a record that the round and team number are the same.
for example:
I want the LA Lakers(Team Nr. 1) to play in Round 1 only ONCE.
and when i will say that they play in round 1 again i wont be able to save the record.

thanks a lot for your help.
 
If you set both of these fields as the Primary Key then it will not allow duplicates.

It will give you a really bad Primary Key Violation error so you might want to trap for it and display something a little bit more cute and fuzzy.
HF
 
I would write some code in the Save button that looked at whether the values were the same and if they weren't then it could save, if they were the same then there would be a message saying that this couldn't happen. You could use the form.undo to make sure that the changes aren't saved.
 
i can't use it as two keys because there can be duplicates just not together.

Team Round

2 1
2 1

can't be!!!

but can be

2 1
2 2
3 1
3 2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top