Freezerbird
New member
- Local time
- Today, 08:46
- Joined
- Aug 9, 2008
- Messages
- 3
I have a table of results from soccer matches (MatchTeams) where each record represents a team in a match and the number of goals they scored. In other words, there are two records for each soccer match, one for the home team and one for the away team (the primary key is a MatchTeamID field).
For each record, I want to assign a number of points based on whether they won or lost the match (2 points for a win, 1 for a draw, 0 for a defeat). This means for each record comparing MatchTeams.Score with the other record that has the same MatchTeamID. I’ve used an IIF statement for this, which works fine in a SELECT query.
My problem is, I actually want to update each record in MatchTeams with these points, in a field MatchTeams.Points. When I use the same IIF statement in an UPDATE query, I get this “operation must use an updateable query" error.
UPDATE MatchTeams SET MatchTeams.Points = IIf([MatchTeams].[Score]=(SELECT Dupe1.Score FROM MatchTeams AS Dupe1 WHERE Dupe1.MatchID=MatchTeams.MatchID AND Dupe1.MatchTeamID<>MatchTeams.MatchTeamID),1,IIf([MatchTeams].[Score]>(SELECT Dupe2.Score FROM MatchTeams AS Dupe2 WHERE Dupe2.MatchID=MatchTeams.MatchID AND Dupe2.MatchTeamID<>MatchTeams.MatchTeamID),2,0));
I don’t get why MatchTeam.Points is not updateable. Any help please?
For each record, I want to assign a number of points based on whether they won or lost the match (2 points for a win, 1 for a draw, 0 for a defeat). This means for each record comparing MatchTeams.Score with the other record that has the same MatchTeamID. I’ve used an IIF statement for this, which works fine in a SELECT query.
My problem is, I actually want to update each record in MatchTeams with these points, in a field MatchTeams.Points. When I use the same IIF statement in an UPDATE query, I get this “operation must use an updateable query" error.
UPDATE MatchTeams SET MatchTeams.Points = IIf([MatchTeams].[Score]=(SELECT Dupe1.Score FROM MatchTeams AS Dupe1 WHERE Dupe1.MatchID=MatchTeams.MatchID AND Dupe1.MatchTeamID<>MatchTeams.MatchTeamID),1,IIf([MatchTeams].[Score]>(SELECT Dupe2.Score FROM MatchTeams AS Dupe2 WHERE Dupe2.MatchID=MatchTeams.MatchID AND Dupe2.MatchTeamID<>MatchTeams.MatchTeamID),2,0));
I don’t get why MatchTeam.Points is not updateable. Any help please?