Everyone please help me make this IIF statement work. I have the following query which is derived from a union query:
SELECT TestHDRPRUnionqryforProdRpt.Date, TestHDRPRUnionqryforProdRpt.Line, TestHDRPRUnionqryforProdRpt.Shift, IIf(IsNull([Customers]![Customer #]),[Workorders]![customer number],[Customers]![Customer Name]) AS [Customer Name], TestHDRPRUnionqryforProdRpt.[Work Order], Workorders.[Part Number] AS Assembly, IIf([TestHdrPRUnionqryforProdRpt].[MyField]="none",[TestHDRPRUnionqryforProdRpt].[Printer Operator ID]) AS PrinterOP, IIf([TestHdrPRUnionqryforProdRpt].[MyField]="A" Or "B",[TestHDRPRUnionqryforProdRpt].[Printer Operator ID]) AS HeaderOP
FROM (Customers RIGHT JOIN Workorders ON Customers.[Customer #] = Workorders.[customer number]) RIGHT JOIN TestHDRPRUnionqryforProdRpt ON Workorders.[WO#] = TestHDRPRUnionqryforProdRpt.[Work Order];
It works up until the IIF statement for HeaderOP. I would like for it to look at the MyField field and if there is an A or B, then pull the name listed in the Printer Operator ID field and if it says none then leave blank. It works in the previous IIF statement for PrinterOp but in the HeaderOp statement it is pulling all of the names irrespective of A, B or none. What am I doing wrong? Thanks in advance for your assistance.
SELECT TestHDRPRUnionqryforProdRpt.Date, TestHDRPRUnionqryforProdRpt.Line, TestHDRPRUnionqryforProdRpt.Shift, IIf(IsNull([Customers]![Customer #]),[Workorders]![customer number],[Customers]![Customer Name]) AS [Customer Name], TestHDRPRUnionqryforProdRpt.[Work Order], Workorders.[Part Number] AS Assembly, IIf([TestHdrPRUnionqryforProdRpt].[MyField]="none",[TestHDRPRUnionqryforProdRpt].[Printer Operator ID]) AS PrinterOP, IIf([TestHdrPRUnionqryforProdRpt].[MyField]="A" Or "B",[TestHDRPRUnionqryforProdRpt].[Printer Operator ID]) AS HeaderOP
FROM (Customers RIGHT JOIN Workorders ON Customers.[Customer #] = Workorders.[customer number]) RIGHT JOIN TestHDRPRUnionqryforProdRpt ON Workorders.[WO#] = TestHDRPRUnionqryforProdRpt.[Work Order];
It works up until the IIF statement for HeaderOP. I would like for it to look at the MyField field and if there is an A or B, then pull the name listed in the Printer Operator ID field and if it says none then leave blank. It works in the previous IIF statement for PrinterOp but in the HeaderOp statement it is pulling all of the names irrespective of A, B or none. What am I doing wrong? Thanks in advance for your assistance.