What I have currently is 2 different queries that pull the same information but with different criteria. I am trying to combine them into 1 query with an IIF statement for the criteria.
The querie is run based on the RepNo that is input on a form. Once the user choose the RepNo from the combo box on the form, they click a botton and it runs the query. If RepNo = 061 then I want the query only to return AcctNo ABC123456, if it is any RepNo other than 061, I don't want it to return CBA123456. Below is what I have come up with, but it will not return any records. If I remove the IIF and only have the criteria <>CBA123456 for the AcctNo, the query works great.
Can someone tell me what I am doing wrong. I am still somewhat of a beginner at IIF statements.
Thanks.
SELECT tblRepCommissions.Acctno, tblRepCommissions.RepNo
FROM tblRepCommissions
WHERE (((tblRepCommissions.Acctno)=IIf(([Forms]![frmBrokerageCommissions]![RepNo]="061"
,("ABC123456"
,((tblRepCommissions.Acctno)<>"CBA123456"
)) AND ((tblRepCommissions.RepNo)=[Forms]![frmBrokerageCommissions]![RepNo]));
The querie is run based on the RepNo that is input on a form. Once the user choose the RepNo from the combo box on the form, they click a botton and it runs the query. If RepNo = 061 then I want the query only to return AcctNo ABC123456, if it is any RepNo other than 061, I don't want it to return CBA123456. Below is what I have come up with, but it will not return any records. If I remove the IIF and only have the criteria <>CBA123456 for the AcctNo, the query works great.
Can someone tell me what I am doing wrong. I am still somewhat of a beginner at IIF statements.
Thanks.
SELECT tblRepCommissions.Acctno, tblRepCommissions.RepNo
FROM tblRepCommissions
WHERE (((tblRepCommissions.Acctno)=IIf(([Forms]![frmBrokerageCommissions]![RepNo]="061"