RogueIT,
I gather that the query you posted does not give the expected results?
In what way is it different from expected?
It is not clear what the purpose of the GROUP BY clause in the query is.
Nor is it clear what the role of the fields from the Count_ID query
play, but I imagine there is only one record returned in this query for
each company, yes? Also, 'count' and 'date' are both Reserved Words
(i.e. have a special meaning) in Access, and as such should not be used
as the name of fileds or controls... but that is unlikely to be causing
the problem. The Last() function returns a random record, probably you
need Max(). Is the data in the [Date] field just a date, or does it
include time data as well? Assuming just a date:
I would try it like this...
SELECT DISTINCT Count_ID.[ID ], Count_ID.CountOfID AS [Count],
Information_coll.[Company Name], Information_coll.[Date]
FROM Information_coll INNER JOIN Count_ID ON Information_coll.[ID] =
Count_ID.[ID]
WHERE Information_coll.[Date]=Date()-1 Or Information_coll.[Date]=Date()-2
ORDER BY Count_ID.CountOfID DESC;
or...
SELECT Count_ID.[ID ], Count_ID.CountOfID AS [Count],
Information_coll.[Company Name ], Max(Information_coll.[Date]) AS MaxOfDate
FROM Information_coll INNER JOIN Count_ID ON Information_coll.[ID] =
Count_ID.[ID]
GROUP BY Count_ID.[ID], Count_ID.CountOfID, Information_coll.[Company Name]
HAVING ((Max(Information_coll.[Date]))=Date()-1 Or
(Max(Information_coll.[Date]))=Date()-2)
ORDER BY Count_ID.CountOfID DESC;
If neither of these help, please let us know what the problem is.
--
Steve Schapel, Microsoft Access MVP
How would I have it only show me only the companies that have entries in the
table for today and yesterday (technically it would be yesterday and day
before that ) so companies that have consecutive days from yesterday
*******************************************
SELECT Count_ID.[ID ], Count_ID.CountOfID AS [Count],
Information_coll.[Company Name ], Last(Information_coll.Date) AS LastOfDate
FROM Information_coll INNER JOIN Count_ID ON Information_coll.[ID ] =
Count_ID.[ID ]
GROUP BY Count_ID.[ID ], Count_ID.CountOfID, Information_coll.[Company Name ]
HAVING (((Last(Information_coll.Date))=Date()-1 Or
(Last(Information_coll.Date))=Date()-2))
ORDER BY Count_ID.CountOfID DESC;
*******************************************