Allen Browne said:
Switch the Query to SQL View (View menu.)
Locate the WHERE clause.
Change it to look like this:
WHERE IIf([Forms]![Frm_DATA Extract]![Area]="SMD", True,
[YourYesNoField])
This works because the WHERE clause is something that evaluates to True
or
False (or Null) for each record. The expression above evaluates to TRUE
for
every record when the Area text box contains SMD. If the text box doesn't
contain that, the WHERE clause evaluates to True only if the text box is
true (checked.)
filip said:
I'm stuck in creating a selection criteria for a query.
Based on a value in a Form, I need to select all records which are
"Yes",
if
this text in the form is "SMD" or, if this value is not "SMD", I want
all
records (both "Yes" and "No").
The first part of the iif statement is no problem and works fine, but
how
can I select all records (what do I need in the falsepart of the iif)?
It looks like I need to use a wildcard here to select all records but I
can't make it work.
IIf([Forms]![Frm_DATA Extract]![Area]="SMD";"Yes"; )
Allen,
Thanks for your comments, but I still didn't make it work. This selection
criteria is only one of the many criterias in this selection query.
Underneath you can find the full SQL view. Everything is working fine
except
this above mentioned problem.
SELECT Tbl_DCAFS_Data.Date, Tbl_DCAFS_Data.NoTec, Tbl_DCAFS_Data.Model,
Tbl_DCAFS_Data.Comp, Tbl_DCAFS_Data.PartNo, Tbl_DCAFS_Data.Defect,
Tbl_lookup_ProfitCtr.[Profit Ctr], Tbl_lookup_ProfitCtr.Area,
IIf(Tbl_Assemblies!SMD=Yes And
Tbl_Problem_Classificatie!SMD=Yes,"Yes","No")
AS SMD, IIf([Station]="Insercion-plant160","Yes","No") AS Visual
FROM Tbl_Problem_Classificatie INNER JOIN ((Tbl_lookup_ProfitCtr INNER
JOIN
Tbl_Assemblies ON Tbl_lookup_ProfitCtr.[Profit Ctr] =
Tbl_Assemblies.[Profit
Ctr]) INNER JOIN Tbl_DCAFS_Data ON Tbl_Assemblies.DCAFS_Model_Name =
Tbl_DCAFS_Data.Model) ON Tbl_Problem_Classificatie.Defect =
Tbl_DCAFS_Data.Defect
WHERE (((Tbl_DCAFS_Data.Date)>=[Forms]![Frm_DATA Extract]![Start_Date] And
(Tbl_DCAFS_Data.Date)<=[Forms]![Frm_DATA Extract]![Stop_Date]) AND
((Tbl_DCAFS_Data.Model)=IIf([Forms]![Frm_DATA Extract]![Model] Is Not
Null,[Forms]![Frm_DATA Extract]![Model],[Tbl_DCAFS_Data]![Model])) AND
((Tbl_DCAFS_Data.PartNo)=IIf([Forms]![Frm_DATA Extract]![Part] Is Not
Null,[Forms]![Frm_DATA Extract]![Part],[Tbl_DCAFS_Data]![PartNo])) AND
((Tbl_DCAFS_Data.Defect)=IIf([Forms]![Frm_DATA Extract]![Defect] Is Not
Null,[Forms]![Frm_DATA Extract]![Defect],[Tbl_DCAFS_Data]![Defect])) AND
((Tbl_lookup_ProfitCtr.Area)=IIf(([Forms]![Frm_DATA
Extract]![Area]<>"ALL")
And ([Forms]![Frm_DATA Extract]![Area]<>"TSUB") And ([Forms]![Frm_DATA
Extract]![Area]<>"SMD"),[Forms]![Frm_DATA Extract]![Area],[Area])) AND
((IIf([Tbl_Assemblies]![SMD]=Yes And
[Tbl_Problem_Classificatie]![SMD]=Yes,"Yes","No"))=IIf([Forms]![Frm_DATA
Extract]![Area]="SMD","Yes")) AND
((Tbl_DCAFS_Data.AreaAffected)=IIf([Forms]![Frm_DATA
Extract]![Area]="TSUB","Manual/Final-Plant160-TSUB",[Tbl_DCAFS_Data]![AreaAffected])))
ORDER BY Tbl_DCAFS_Data.Date;