Link to home
Start Free TrialLog in
Avatar of linbayzak
linbayzakFlag for United States of America

asked on

need criteria to pull data from today and yesterday in microsoft access

Hi Experts,

I have a combo box with a rowsource of

SELECT [Scrap Ticket].ID, [Scrap Ticket].[Date Shift Run:], [Scrap Ticket].GLPart, [Scrap Ticket].[Material Type:], [Scrap Ticket].[Tube Description:]
FROM [Scrap Ticket]
WHERE ((([Scrap Ticket].Operator)=[Forms]![Switchboard]![txtUserName]))
GROUP BY [Scrap Ticket].ID, [Scrap Ticket].[Date Shift Run:], [Scrap Ticket].GLPart, [Scrap Ticket].[Material Type:], [Scrap Ticket].[Tube Description:]
HAVING ((([Scrap Ticket].[Date Shift Run:])>=Date() And ([Scrap Ticket].[Date Shift Run:])=Date()-1))
ORDER BY [Scrap Ticket].[Date Shift Run:] DESC;

which i thought would pick up all entries for this user between yesterday and today so that the third shift will still be able to access their data entered on that shift even after the date changes at midnight.

Is something wrong with my criteria.....

Date() AND Date()-1

Thanks
Laura
ASKER CERTIFIED SOLUTION
Avatar of DoveTails
DoveTails
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And ([Scrap Ticket].[Date Shift Run:])=Date()-1))

These rules are impossible to meet.  If the date must be equal to yesterday it cannot also be greater than or equl to today.

Unless you have records going into the future then  all you need is..
HAVING [Scrap Ticket].[Date Shift Run:]>=Date()-1
Avatar of linbayzak

ASKER

perfect, thanks :-)