Solved

Simple Access Query

Posted on 2013-06-13
5
298 Views
Last Modified: 2013-06-13
I have a table with the following data describing the schedule for a certain employee.  

ID* EmpID      EffectiveDate    InSched     Weekday
1    123           1/1/2000           9:30AM      Mon
2    123           1/1/2000           9:30AM      Tue
3    123           1/1/2000           9:30AM      Wed
4    123           1/1/2000           9:30AM      Thu
5    123           1/1/2000           9:30AM      Fri
6    123           1/1/2001           9:15AM      Mon    

I'd like the query to eliminate line 5 because line 6 shows a newer schedule for employee 123 for Mondays.

EffectiveDate and InSched fields are Date/Time fields.  The Weekday field is just short text.

Any help will be much appreciated.
0
Comment
Question by:colin911
5 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 39245447
Aren't you wanting to eliminate line 1 instead of 5?
OM Gang
0
 

Author Comment

by:colin911
ID: 39245495
Ha!  Yes, Sorry!  Trying to multi-task and I'm not good at that!
0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 39245550
A bit confused by your data examples ...

Will each weekday share the same effective date?
Will it always be 5 days (Mon thru Fri) for each employee?

ET
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 39245571
You need 2 queries or query-in-query (you table is Table1 - replace with real name):
SELECT Table1.ID, Table1.EmpID, Table1.EffectiveDate, Table1.InSched, Table1.Weekday
FROM Table1 INNER JOIN (SELECT Table1.EmpID, Max(Table1.EffectiveDate) AS MaxOfEffectiveDate, Table1.Weekday
FROM Table1 GROUP BY Table1.EmpID, Table1.Weekday
ORDER BY Max(Table1.EffectiveDate)) as Query0 ON (Table1.Weekday = Query0.Weekday) AND (Table1.EffectiveDate = Query0.MaxOfEffectiveDate) AND (Table1.EmpID = Query0.EmpID);

Open in new window

0
 

Author Closing Comment

by:colin911
ID: 39245600
thanks!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

19 Experts available now in Live!

Get 1:1 Help Now