how to find all records entered yesterday and none today

hmho

Registered User.
Local time
Yesterday, 20:27
Joined
Apr 7, 2009
Messages
93
I have table for daily data entry and it has these fields [ID],[ReportDate][ProdNumber],[SerialNumber], [Status] and [EndingNumber] and the table name is [DailyReports]. What I like to have is query that will give me all products that had [EndingNumber] the day before where the [Status]=1 but has no entry on today. The reason is I like to find if someone forgot to enter product that should have ending number.

attached the data here. In the query MissigSales product with serial number 0789-100000 there were ending number yesterday but no data entry with today's date. I would like the query to show this product.

Thanks
 

Attachments

Last edited:
I have table for daily data entry and it has these fields [ID],[ReportDate][ProdNumber],[SerialNumber], [Status] and [EndingNumber] and the table name is [DailyReports]. What I like to have is query that will give me all products that had [EndingNumber] the day before where the [Status]=1 but has no entry on today. The reason is I like to find if someone forgot to enter product that should have ending number.

attached the data here. In the query MissigSales product with serial number 0789-100000 there were ending number yesterday but no data entry with today's date. I would like the query to show this product.

Thanks
I don't think you can do with one query here. you have two criteria for the ENDINGNUMBER, and one needs a subquery.

maybe this would work:
Code:
SELECT * FROM DailyReports
   WHERE [Status] = 1 AND [EndingNumber] Is Null
Then a stacked query on top of that:
Code:
SELECT * FROM query
   WHERE [EndingNumber] Is Not Null AND
      [ReportDate] = DateAdd("d", -1, Date())
 
I don't think you can do with one query here. you have two criteria for the ENDINGNUMBER, and one needs a subquery.

maybe this would work:
Code:
SELECT * FROM DailyReports
   WHERE [Status] = 1 AND [EndingNumber] Is Null
Then a stacked query on top of that:
Code:
SELECT * FROM query
   WHERE [EndingNumber] Is Not Null AND
      [ReportDate] = DateAdd("d", -1, Date())

I'm not sure how to do subquery but when I tried this I got error.
 
Try this sql

Code:
SELECT TbleDailyReports.ID, 
TbleDailyReports.ReportDate, 
TbleDailyReports.ProductNumber, 
TbleDailyReports.SerialNumber, 
TbleDailyReports.Status, 
TbleDailyReports.EndingNumber, 
TbleDailyReports_1.ProductNumber
FROM TbleDailyReports LEFT JOIN 
TbleDailyReports AS TbleDailyReports_1 ON 
(TbleDailyReports.ReportDate = TbleDailyReports_1.ReportDate-1) AND 
(TbleDailyReports.ProductNumber = TbleDailyReports_1.ProductNumber) AND 
(TbleDailyReports.SerialNumber = TbleDailyReports_1.SerialNumber)
WHERE (((TbleDailyReports.ReportDate)=Date()-1) AND 
((TbleDailyReports.Status)=1) AND 
((TbleDailyReports.EndingNumber) Is Not Null) AND
 ((TbleDailyReports_1.ProductNumber) Is Null));
 

Users who are viewing this thread

Back
Top Bottom