Yes. The issue is, what constitutes a year? In your example, Employee 1 takes Annual Leave that spans Calendar years. You may use a Fiscal Year, so you will have spanning issues you need to resolve. Is part of the leave attributed to each year, or to the start year, or the end year?
Also, I thought DateDiff() was a reserved word. How is it that you are getting this public function to work when it already exists?
Where are these results sent to? For example, where are you getting the EmployeeID in this code? Assuming that you are storing these results in a query with the fields you indicated, create a second query that looks like this:
SELECT EmpNo, DatePart("yyyy", DateFrom) As DateYear, Sum(NumOfDays) As SumDays
FROM qryMyQuery
WHERE DateYear = [Forms]![MyForm].[MyYearContol]
This will allow a user to select a year, for example 2007, and show the following results if 2007 is selected:
EmpNo DateYear SumDays
1 2007 2
This assumes the start date is the leave year.
Did any of that help?
mmcdonal
Look it up at:
http://wrox.books24x7.com