I have a query that has a product code field and an Agent Number field.
The Product code field data looks like this XXAW24, XXUT12 etc.
The Agent Number filed data looks like this 29221 and 67322
The product code filed is called "strProductCode" and the agent number field is called "strAgentNo"
Product codes that end in 24 are always associated with agent number 67322 and product codes that end in 12 are always associated with agent number 29221.
In my query I have written the follow IIF function:
AgentNo: IIf([strAgentNo]="67322",IIf(Right([strProductCode],2)="12","29221",IIf([strAgentNo]="29221",IIf(Right([strProductCode],2)="24","67322",[strAgentNo]))))
Now it corrects the records where the agent number is 67322 were the right two characters of the product code field are 12, but it doesn correct the records where the agent number is 29221 and the right two characters of the product code field are 24 and where records do not meet any of these criteria, it doesn't retain the agent number at all, the field is blank in these cases.
Clearly I must be doing something wrong, but I can't seem to work out where that is, some assistance would be appreciated.
John
The Product code field data looks like this XXAW24, XXUT12 etc.
The Agent Number filed data looks like this 29221 and 67322
The product code filed is called "strProductCode" and the agent number field is called "strAgentNo"
Product codes that end in 24 are always associated with agent number 67322 and product codes that end in 12 are always associated with agent number 29221.
In my query I have written the follow IIF function:
AgentNo: IIf([strAgentNo]="67322",IIf(Right([strProductCode],2)="12","29221",IIf([strAgentNo]="29221",IIf(Right([strProductCode],2)="24","67322",[strAgentNo]))))
Now it corrects the records where the agent number is 67322 were the right two characters of the product code field are 12, but it doesn correct the records where the agent number is 29221 and the right two characters of the product code field are 24 and where records do not meet any of these criteria, it doesn't retain the agent number at all, the field is blank in these cases.
Clearly I must be doing something wrong, but I can't seem to work out where that is, some assistance would be appreciated.
John