I know how to display all the records if no parameters are selected on the form. But my user is adamant about having the "All" option in dropdown menu and he would like to see all the records if that option is selected. Currently, the query would display all the records if no selection is made for the Controls CmbLocation or CmbType. The options in CmbLocations are names of 9 different locations. The user would like the 10th option "All". I don't know how to show all records if the option "All" is selected.
Any help is appreciated. Thanks in advance.
Given below is my query
SELECT tblLeaveRequest.Location, tblLeaveRequest.Type, tblLeaveRequest.StartDate, tblLeaveRequest.EndDate, iif([Forms]![Analysis].[StartDate]>[StartDate],[Forms]![Analysis].[StartDate],[StartDate]) as UsedStartdate,
iif([Forms]![Analysis].[EndDate]<[EndDate],[Forms]![Analysis].[EndDate],[EndDate]) as UsedEnddate,
funWorkDaysDifference(iif([Forms]![Analysis].[StartDate]>[StartDate],[Forms]![Analysis].[StartDate],[StartDate]),
iif([Forms]![Analysis].[EndDate]<[EndDate],[Forms]![Analysis].[EndDate],[EndDate]))
AS WorkDaysDifference
FROM tblLeaveRequest
WHERE ((([Forms]![Analysis].[cmbLocation]) Is Null) or (tblLeaveRequest.Location)=[Forms]![Analysis].[cmbLocation])
AND ((([Forms]![Analysis].[cmbType]) is null) or (tblLeaveRequest.Type)=[Forms]![Analysis].[cmbType])
AND (((tblLeaveRequest.EndDate)>=[Forms]![Analysis].[StartDate]) AND ((tblLeaveRequest.StartDate)<=[Forms]![Analysis].[EndDate]))
AND (tblLeaveRequest.Approved = "YES")
Any help is appreciated. Thanks in advance.
Given below is my query
SELECT tblLeaveRequest.Location, tblLeaveRequest.Type, tblLeaveRequest.StartDate, tblLeaveRequest.EndDate, iif([Forms]![Analysis].[StartDate]>[StartDate],[Forms]![Analysis].[StartDate],[StartDate]) as UsedStartdate,
iif([Forms]![Analysis].[EndDate]<[EndDate],[Forms]![Analysis].[EndDate],[EndDate]) as UsedEnddate,
funWorkDaysDifference(iif([Forms]![Analysis].[StartDate]>[StartDate],[Forms]![Analysis].[StartDate],[StartDate]),
iif([Forms]![Analysis].[EndDate]<[EndDate],[Forms]![Analysis].[EndDate],[EndDate]))
AS WorkDaysDifference
FROM tblLeaveRequest
WHERE ((([Forms]![Analysis].[cmbLocation]) Is Null) or (tblLeaveRequest.Location)=[Forms]![Analysis].[cmbLocation])
AND ((([Forms]![Analysis].[cmbType]) is null) or (tblLeaveRequest.Type)=[Forms]![Analysis].[cmbType])
AND (((tblLeaveRequest.EndDate)>=[Forms]![Analysis].[StartDate]) AND ((tblLeaveRequest.StartDate)<=[Forms]![Analysis].[EndDate]))
AND (tblLeaveRequest.Approved = "YES")