Below is the complete SQL statement. What I envision is being able to select
a FY on a form, and pull positions that were active on or before that FY but
did not end until after the FY. Our FY is July - June.
SELECT tblPersonnel.Department, tblPositions.PositionType,
tblPersonnel.LastName, tblPersonnel.FirstName, tblPersonnel.CurrentAssignNo,
tblPositions.OracleTitle, tblPositions.FTE, tblPositions.ApptLength,
tblPersonnelAction.ActionType, tblPersonnelAction.ActionDate,
tblPersonnelAction.ActionValue, tblSalComponents.FiscalYear,
tblSalComponents.BaseAfterRaise, tblSalComponents.EnhancementAR,
tblSalComponents.ProvostInitiativeAR, tblSalComponents.SpecInitMinHireAR,
tblSalComponents.AdminSuppSummer, tblSalComponents.AdminSuppAR,
tblSalComponents.AdminStipAR, tblSalComponents.Professorship,
tblSalComponents.TotalBeforeLongevity, tblPositions.PositionStartDate,
tblPositions.PositionEndDate,
Year([PositionEndDate])-IIf([PositionEndDate]<DateSerial(Year([PositionEndDate]),7,1),1,0)+1
AS FYearEnd,
Year([PositionStartDate])-IIf([PositionStartDate]<DateSerial(Year([PositionStartDate]),7,1),1,0)+1 AS FYearStart
FROM ((tblPersonnel INNER JOIN tblPositions ON tblPersonnel.EmployeeID =
tblPositions.EmployeeID) INNER JOIN tblSalComponents ON
tblPersonnel.EmployeeID = tblSalComponents.EmployeeID) INNER JOIN
tblPersonnelAction ON tblPersonnel.EmployeeID = tblPersonnelAction.EmployeeID
WHERE (((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"FT",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear]) AND
((Year([PositionEndDate])-IIf([PositionEndDate]<DateSerial(Year([PositionEndDate]),7,1),1,0)+1)>=[Forms]![frmReports]![FiscalYear])
AND
((Year([PositionStartDate])-IIf([PositionStartDate]<DateSerial(Year([PositionStartDate]),7,1),1,0)+1)<=[Forms]![frmReports]![FiscalYear]))
OR (((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"FT",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear])) OR
(((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"PD",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear])) OR
(((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"PD",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear])) OR
(((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"FN",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear])) OR
(((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"FN",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear])) OR
(((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"FX",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear])) OR
(((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"FX",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear])) OR
(((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"AP",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear])) OR
(((tblPersonnel.Department) Like IIf([Forms]![frmReports]![Combo14] Is
Null,"*",[Forms]![frmReports]![Combo14])) AND ((tblPositions.PositionType)
Like IIf([Forms]![frmReports]![PositionType] Is
Null,"AP",[Forms]![frmReports]![PositionType])) AND
((tblPersonnelAction.ActionType)="hired") AND
((tblSalComponents.FiscalYear)=[Forms]![frmReports]![FiscalYear]))
ORDER BY tblPersonnel.Department;
KARL DEWEY said:
year of the start date, and greater than the fiscal year of the end date.
You also did not say what your fiscal year is (everyone does not use the same
fiscal year).
I can not follow your criteria statement. Which records below would you
want to pull?
Record Start Date End Date
1 2006 2006
2 2006 2007
3 2006 2008
4 2006 2009
5 2006 2010
6 2007 2007
7 2007 2008
8 2007 2009
9 2007 2010
10 2008 2006
11 2008 2007
12 2008 2008
13 2008 2009
14 2008 2010
15 2009 2007
16 2009 2008
17 2009 2009
18 2009 2010
19 2010 2006
20 2010 2007
21 2010 2008
22 2010 2009
23 2010 2010