Background:
I have a table call tblTeams. In it i have Player1ID & Player2ID. The IDs stored in tblTeams come from table tblPlayers and each ID is unique in tblPlayers.
In tblTeams records are created by selecting 2 players from tblPlayers. Each record in tblTeams is unique
tblTeams fields (other fields exist but not relavent to my issue)
ID (AutoNumber)
Player1ID (Number)
Player2ID (Number)
If I create record int tblTeams like:
ID Player1ID Player2ID
1 10 20
2 11 12
3 24 32
Scenario1:
I try to add another record: "10" as Player1ID "20" as Player2ID
I unique compound key on Player1ID & Player2ID will prevent that - that works fine
Scenario2:
I try to add another record: "20" as Player1ID "10" as Player2ID
The compound key will not catch that - thats not good!
Question:
Is there a way to create a unique identifier so that any combination of "10" & "20" will not be allowed once that combination is used?
Any type of math addition of the values would fail do to other combination of IDs equating to the same sum value.
Possible options: (Don't know how to do these- help would be appreciated!)
1) Maybe restricting the entry of a lower Player2ID then a Player1ID in the form
2) Or, before_update possibly, looping thru the recordset to see if Player1ID and Player2ID have been used (seems to be not an efficient way to check)
I welcome any ideas with open arms!!!
Thanks Rick
I have a table call tblTeams. In it i have Player1ID & Player2ID. The IDs stored in tblTeams come from table tblPlayers and each ID is unique in tblPlayers.
In tblTeams records are created by selecting 2 players from tblPlayers. Each record in tblTeams is unique
tblTeams fields (other fields exist but not relavent to my issue)
ID (AutoNumber)
Player1ID (Number)
Player2ID (Number)
If I create record int tblTeams like:
ID Player1ID Player2ID
1 10 20
2 11 12
3 24 32
Scenario1:
I try to add another record: "10" as Player1ID "20" as Player2ID
I unique compound key on Player1ID & Player2ID will prevent that - that works fine
Scenario2:
I try to add another record: "20" as Player1ID "10" as Player2ID
The compound key will not catch that - thats not good!
Question:
Is there a way to create a unique identifier so that any combination of "10" & "20" will not be allowed once that combination is used?
Any type of math addition of the values would fail do to other combination of IDs equating to the same sum value.
Possible options: (Don't know how to do these- help would be appreciated!)
1) Maybe restricting the entry of a lower Player2ID then a Player1ID in the form
2) Or, before_update possibly, looping thru the recordset to see if Player1ID and Player2ID have been used (seems to be not an efficient way to check)
I welcome any ideas with open arms!!!
Thanks Rick