Interrogating a subset within a dataset

Ivan Howard

Active Member
Joined
Nov 10, 2004
Messages
333
Hello all,

I'm struggling with an Access (2010) issue and if someone could help me I'd really appreciate it as it is driving me nuts!

I have a 10000+ record dataset that has multiple records per person. The dataset looks like this:

Employee_IDEmployee_NameDept_Start_DateDept_End_Date
EE101James Simpson01/01/201727/03/2017
EE101James Simpson28/03/201707/06/2014
EE325Michelle Brown01/01/201722/01/2017
EE325Michelle Brown19/01/201707/06/2017
EE687John Smith01/01/201706/05/2017
EE687John Smith07/05/201707/05/2017
EE687John Smith08/05/201707/06/2017

<tbody>
</tbody>



What I need to do for EACH person is validate that the "Dept_Start_Date" on record 2 is before the "Dept_End_Date"s on record 1, and so forth. One person could have 12 records.

In the case of Michelle Brown above, the second record has an earlier start date so would like to be able to show those "errors" in a query so that they can be manually checked and updated if needed. Happy to have an additional TRUE/FALSE field to update if an "error" is found so that I can isolate the records to check.

I'm not sure if standard queries can be used or if VBA has to be used as it is easier and probably more efficient... I'm happy with VBA but just don't know how to get to the results.

Any help would be fantastic.

Thanks very much.
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
you need a series of validation queries, in a macro

Q1:
SELECT tData.Employee_ID, tData.Employee_Name, tData.Dept_Start_Date, tData.Dept_End_Date, "EndDate is earlier thatn StartDate" AS [Note]
FROM tData
WHERE (((tData.Dept_End_Date)<[Dept_Start_Date]));


Q2:
SELECT tData.Employee_ID, tData.Employee_Name, tData.Dept_Start_Date, tData.Dept_End_Date, tData_1.Dept_Start_Date, tData_1.Dept_End_Date, "Overlapping Ranges" AS [Note]
FROM tData INNER JOIN tData AS tData_1 ON tData.Employee_ID = tData_1.Employee_ID
WHERE (((tData.Dept_Start_Date)<[tData_1].[Dept_Start_Date]) AND ((tData.Dept_End_Date)>[tData_1].[Dept_Start_Date]));

etc...
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,214,858
Messages
6,121,960
Members
449,057
Latest member
FreeCricketId

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top