T
tonyrusin
Hi,
I have a subform based on a query the uses criteria from the parent
form. So, depending on what information is filled in the text boxes on
the main form, the subform will filter based on that. I have all of it
working but one part I'm having trouble with is a number range using
an IIf statement.
Here is the syntax I'm having issues with (built in the query builder
and converted to SQL):
SELECT tblTaskBoat.*
FROM tblTaskBoat
WHERE (((tblTaskBoat.WeekNo)=IIf(Not
(tblTaskBoat.WeekNo)=IsNull([Forms]![frmSchedule]![txtWeekNoStart]),(tblTaskBoat.WeekNo)>=[Forms]![frmSchedule]![txtWeekNoStart])
And (tblTaskBoat.WeekNo)=IIf(Not
(tblTaskBoat.WeekNo)=IsNull([Forms]![frmSchedule]![txtWeekNoEnd]),(tblTaskBoat.WeekNo)<=[Forms]![frmSchedule]![txtWeekNoEnd])));
The Criteria field in the query builder has this:
IIf(Not
IsNull([Forms]![frmSchedule]![txtWeekNoStart]),>=[Forms]![frmSchedule]![txtWeekNoStart])
And IIf(Not
IsNull([Forms]![frmSchedule]![txtWeekNoEnd]),>=[Forms]![frmSchedule]![txtWeekNoEnd])
I started simple just using a half of the query (not attempting a date
range) but I can't even get that to work:
SELECT tblTaskBoat.*
FROM tblTaskBoat
WHERE (((tblTaskBoat.WeekNo)=IIf(Not
(tblTaskBoat.WeekNo)=IsNull([Forms]![frmSchedule]![txtWeekNoStart]),(tblTaskBoat.WeekNo)>=[Forms]![frmSchedule]![txtWeekNoStart])));
Criteria:
IIf(Not
IsNull([Forms]![frmSchedule]![txtWeekNoStart]),>=[Forms]![frmSchedule]![txtWeekNoStart])
What I'm after is if the field on the parent form is null then I
don't want the query to filter based on it, if it's not null then
show greater than or equal to that number or vise-versa for the other
field.
Any help is greatly appreciated. Thanks!
- Tony
I have a subform based on a query the uses criteria from the parent
form. So, depending on what information is filled in the text boxes on
the main form, the subform will filter based on that. I have all of it
working but one part I'm having trouble with is a number range using
an IIf statement.
Here is the syntax I'm having issues with (built in the query builder
and converted to SQL):
SELECT tblTaskBoat.*
FROM tblTaskBoat
WHERE (((tblTaskBoat.WeekNo)=IIf(Not
(tblTaskBoat.WeekNo)=IsNull([Forms]![frmSchedule]![txtWeekNoStart]),(tblTaskBoat.WeekNo)>=[Forms]![frmSchedule]![txtWeekNoStart])
And (tblTaskBoat.WeekNo)=IIf(Not
(tblTaskBoat.WeekNo)=IsNull([Forms]![frmSchedule]![txtWeekNoEnd]),(tblTaskBoat.WeekNo)<=[Forms]![frmSchedule]![txtWeekNoEnd])));
The Criteria field in the query builder has this:
IIf(Not
IsNull([Forms]![frmSchedule]![txtWeekNoStart]),>=[Forms]![frmSchedule]![txtWeekNoStart])
And IIf(Not
IsNull([Forms]![frmSchedule]![txtWeekNoEnd]),>=[Forms]![frmSchedule]![txtWeekNoEnd])
I started simple just using a half of the query (not attempting a date
range) but I can't even get that to work:
SELECT tblTaskBoat.*
FROM tblTaskBoat
WHERE (((tblTaskBoat.WeekNo)=IIf(Not
(tblTaskBoat.WeekNo)=IsNull([Forms]![frmSchedule]![txtWeekNoStart]),(tblTaskBoat.WeekNo)>=[Forms]![frmSchedule]![txtWeekNoStart])));
Criteria:
IIf(Not
IsNull([Forms]![frmSchedule]![txtWeekNoStart]),>=[Forms]![frmSchedule]![txtWeekNoStart])
What I'm after is if the field on the parent form is null then I
don't want the query to filter based on it, if it's not null then
show greater than or equal to that number or vise-versa for the other
field.
Any help is greatly appreciated. Thanks!
- Tony