Solved

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

Posted on 2011-03-16
3
531 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:linbayzak
3 Comments
 
LVL 5

Accepted Solution

by:
DoveTails earned 500 total points
Comment Utility
May want to try using only the greater than or equal to date minus one:

HAVING [Scrap Ticket].[Date Shift Run:]>=Date()-1)
0
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
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
0
 

Author Closing Comment

by:linbayzak
Comment Utility
perfect, thanks :-)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now