D
DNuding
Sorry to repost this, but I was not sure I would get help with this again and
it would get lost in the list.
As suggested, I created a table called ExcludeShows1 with the ShowID and
Year fields. I have posted the SQL with those changes
to the query. When I tested this initially, it appeared to work. Then I
tried testing the queries using last year's show data for 2009. No data is
being
returned for 2009. Not sure what is happening that it is not returning 2009
data.
SELECT Shows.ShowID, Entries.Place,
IIf([Entries]>1,([Entries]-[Place])*0.5,0) AS Points1, IIf([Entries]>3 And
[Place]=1,1,0) AS Bonus,
IIf([Points1]+[Bonus]>CInt(Nz(Choose([Place],7,5,4,3,2,1),0)),CInt(Nz(Choose([Place],7,5,4,3,2,1),0)),[Points1]+[Bonus])
AS Points, Classes.Entries, Entries.ClassID, Classes.ClassNum,
Horses.HorseName, OwnersandRiders.FullName, Horses.HPNominatedYear,
Horses.NWHATRNumber, Horses.Title, Horses.Titles, Horses.Suspended,
Shows.StartDate, OwnersandRiders.NWHAMemDate, Shows.Year, Classes.NWHAHP,
NWHAHPCategories.HPDescription, OwnersandRiders.NWHAMember,
OwnersandRiders.Suspended, OwnersandRiders.AddField, Entries.Rider,
OwnersandRiders_1.NWHAMember, OwnersandRiders_1.NWHAMemDate
FROM Shows INNER JOIN (OwnersandRiders INNER JOIN (Horses INNER JOIN
((NWHAHPCategories INNER JOIN Classes ON NWHAHPCategories.NWHAHP =
Classes.NWHAHP) INNER JOIN (Entries INNER JOIN OwnersandRiders AS
OwnersandRiders_1 ON Entries.Rider = OwnersandRiders_1.FullName) ON
Classes.ClassID = Entries.ClassID) ON Horses.HorseName = Entries.HorseName)
ON OwnersandRiders.OwnerRiderID = Entries.OwnerRiderID) ON (Shows.Name =
Classes.ShowName) AND (Shows.ShowID = Classes.ShowID)
WHERE Shows.ShowID NOT IN (SELECT ShowID FROM ExcludeShows1 WHERE Year =
Year(Date()))
AND ((Horses.HPNominatedYear)=CStr(Year(Date())))
AND ((Horses.Suspended)="N")
AND ((Shows.StartDate)>=[Ownersandriders].[NwhaMemDate])
AND ((Shows.Year)=CStr(Year(Date())))
AND ((Classes.NWHAHP)<>"NA")
AND ((OwnersandRiders.NWHAMember)="yes")
AND ((OwnersandRiders.Suspended)="N")
AND ((OwnersandRiders_1.NWHAMember)="Yes")
AND ((OwnersandRiders_1.NWHAMemDate)<[Shows].[Startdate])
ORDER BY Entries.Place, Classes.Entries;
In the ExcludeShows1 table I have 2 fields: ShowID and Year with Lookups by
query to the Shows table for those 2 fields. I entered 2009 ShowIDs and
2009 as the year for each show. When I run the above query, no
records are returned. The ExcludeShows1 table is populated with 7 records.
I thought that the query should return records for the 31 shows for 2009 to
Include. In the Shows table, the Year
field was setup as Text, in the ExcludeShows1 table it is set up as text to
match.
This is the year format for the Shows.Year and Horses.HPNomincatedYear fields.
CStr(Year(Date())). With those fields set up as text, should this be
different?
Thanks again for your help.
it would get lost in the list.
As suggested, I created a table called ExcludeShows1 with the ShowID and
Year fields. I have posted the SQL with those changes
to the query. When I tested this initially, it appeared to work. Then I
tried testing the queries using last year's show data for 2009. No data is
being
returned for 2009. Not sure what is happening that it is not returning 2009
data.
SELECT Shows.ShowID, Entries.Place,
IIf([Entries]>1,([Entries]-[Place])*0.5,0) AS Points1, IIf([Entries]>3 And
[Place]=1,1,0) AS Bonus,
IIf([Points1]+[Bonus]>CInt(Nz(Choose([Place],7,5,4,3,2,1),0)),CInt(Nz(Choose([Place],7,5,4,3,2,1),0)),[Points1]+[Bonus])
AS Points, Classes.Entries, Entries.ClassID, Classes.ClassNum,
Horses.HorseName, OwnersandRiders.FullName, Horses.HPNominatedYear,
Horses.NWHATRNumber, Horses.Title, Horses.Titles, Horses.Suspended,
Shows.StartDate, OwnersandRiders.NWHAMemDate, Shows.Year, Classes.NWHAHP,
NWHAHPCategories.HPDescription, OwnersandRiders.NWHAMember,
OwnersandRiders.Suspended, OwnersandRiders.AddField, Entries.Rider,
OwnersandRiders_1.NWHAMember, OwnersandRiders_1.NWHAMemDate
FROM Shows INNER JOIN (OwnersandRiders INNER JOIN (Horses INNER JOIN
((NWHAHPCategories INNER JOIN Classes ON NWHAHPCategories.NWHAHP =
Classes.NWHAHP) INNER JOIN (Entries INNER JOIN OwnersandRiders AS
OwnersandRiders_1 ON Entries.Rider = OwnersandRiders_1.FullName) ON
Classes.ClassID = Entries.ClassID) ON Horses.HorseName = Entries.HorseName)
ON OwnersandRiders.OwnerRiderID = Entries.OwnerRiderID) ON (Shows.Name =
Classes.ShowName) AND (Shows.ShowID = Classes.ShowID)
WHERE Shows.ShowID NOT IN (SELECT ShowID FROM ExcludeShows1 WHERE Year =
Year(Date()))
AND ((Horses.HPNominatedYear)=CStr(Year(Date())))
AND ((Horses.Suspended)="N")
AND ((Shows.StartDate)>=[Ownersandriders].[NwhaMemDate])
AND ((Shows.Year)=CStr(Year(Date())))
AND ((Classes.NWHAHP)<>"NA")
AND ((OwnersandRiders.NWHAMember)="yes")
AND ((OwnersandRiders.Suspended)="N")
AND ((OwnersandRiders_1.NWHAMember)="Yes")
AND ((OwnersandRiders_1.NWHAMemDate)<[Shows].[Startdate])
ORDER BY Entries.Place, Classes.Entries;
In the ExcludeShows1 table I have 2 fields: ShowID and Year with Lookups by
query to the Shows table for those 2 fields. I entered 2009 ShowIDs and
2009 as the year for each show. When I run the above query, no
records are returned. The ExcludeShows1 table is populated with 7 records.
I thought that the query should return records for the 31 shows for 2009 to
Include. In the Shows table, the Year
field was setup as Text, in the ExcludeShows1 table it is set up as text to
match.
This is the year format for the Shows.Year and Horses.HPNomincatedYear fields.
CStr(Year(Date())). With those fields set up as text, should this be
different?
Thanks again for your help.