Solved

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

Posted on 2011-03-16
3
535 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
ID: 35149873
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
ID: 35149877
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
ID: 35150649
perfect, thanks :-)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

786 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