add date as a criteria in pulling records

add date as a criteria in pulling records

Hi,
How do you include a field in a form that is part of a "for each x in AssignedSites.sort()" -  AssignedSites is a result of a list created by another "for each statement".
 
I want to add a date reference in the for each statement to pull put dates within a range.
 
Here is the code
 
for each x in AssignedSites.sort()
{
 xx=AssignedSites.size();

 ThisSite = Customer_Info[ID == x];

 ThisInspection = Inspections[(ID == AssignedSites && (Next_Inspection_Due <= Next_Inspection_Due.addDay(input.Fire_Inspection_Range))) ];

 Upcoming_Inspection:ui.add(ThisSite.Site_ID + " - " + ThisInspection.Type_of_Inspection + " - " + ThisInspection.Next_Inspection_Due);
 
}
 
I'm receiving the ERROR Variable 'Next_Inspection_Due' is not defined

 

Isn't it part of the syntax by default because [Inspections] is the referenced form?