I have two tables - TblCompetitor and TblWinners. TblCompetitor contains details for competitors for the current year and TblWinners contains details of competitors from previous years such as the class in which they were competing and details of the prizes they had won.
I have written the following query in order to compare the names of current competitors with the names in the Winners table to ensure that they have not been entered for competitions for which they are no longer eligable, or that they have been entered in the wrong class.
The problem is that, whilst this code extracts the names of previous winners from TblWinners, it is not extracting the data for each year. ie. for an entry in TblCompetitor there should be up to four records in TblWinners. The code is extracting two records for one competitor, where there should be four, and one record for another competitor, where there should be five. It is not reliable.
I suspect I am using a Select query where I should be using something else but I would appreciate any advice.
Best Regards
John
I have written the following query in order to compare the names of current competitors with the names in the Winners table to ensure that they have not been entered for competitions for which they are no longer eligable, or that they have been entered in the wrong class.
Code:
SELECT TblCompetitor.TxtUnit, TblCompetitor.TxtName, TblCompetitor.TxtInitials, TblCompetitor.TxtServiceNumber, TblCompetitor.TxtRank_Rating, TblCompetitor.TxtClass, TblWinners.TxtClass AS [Previous Class], TblWinners.fPetersPrize, TblWinners.fWonPeters AS Peters, TblWinners.fWrnWinner AS Mersey, TblWinners.fISTeam AS [IS TEAM], TblWinners.fWonTyne AS Tyne, TblWinners.fWonTurtle AS Turtle, Right([BisleyYear] & '',4) AS [Year]
FROM TblCompetitor INNER JOIN TblWinners ON TblCompetitor.TxtName = TblWinners.TxtName
WHERE (((TblCompetitor.TxtName) Is Not Null) AND ((TblWinners.fWonPeters)=True)) OR (((TblWinners.fWrnWinner)=True)) OR (((TblWinners.fISTeam)=True)) OR (((TblWinners.fWonTyne)=True)) OR (((TblWinners.fWonTurtle)=True))
ORDER BY TblCompetitor.TxtUnit, TblCompetitor.TxtName;
The problem is that, whilst this code extracts the names of previous winners from TblWinners, it is not extracting the data for each year. ie. for an entry in TblCompetitor there should be up to four records in TblWinners. The code is extracting two records for one competitor, where there should be four, and one record for another competitor, where there should be five. It is not reliable.
I suspect I am using a Select query where I should be using something else but I would appreciate any advice.
Best Regards
John