I am trying to make a query in MS Access SQL, but i am getting an error in the output table in the field.
- my [ReceiptYesNo] is number with NULL, 1, 2 in the table.
- my [FinancesMemo] is a text.
My first try:
iif(ReceiptYesNo IS NOT NULL,
iif(left(FinancesMemo, 6)="ΙΕΠ //", 3, iif(ReceiptYesNo=1, 1, 2)),
iif(left(FinancesMemo, 6)="ΙΕΠ //", 3, "NULL")
)
AS receipt_id,
My second try:
iif(left(FinancesMemo, 6)="ΙΕΠ //", 3, iif(ReceiptYesNo=1, 1, iif(ReceiptYesNo=2, 2, "NULL"))) as receipt_id,
If the result is something else than "NULL" it is working.
If my result is "NULL", i am getting error in the field.
If i change the code and put something else like "11" or "23", it is working.
How can i make it work?
*** UPDATE ***
It seems i can't put text but only number.
*** After following the answer below(June7), i solve my problem as ***
iif(ReceiptYesNo IS NOT NULL,
iif(left(FinancesMemo, 6)="ΙΕΠ //", 3, iif(ReceiptYesNo=1, 1, 2)),
iif(left(FinancesMemo, 6)="ΙΕΠ //", 3, NULL)
) AS temp_receipt_id,
iif(temp_receipt_id is null,"NULL",temp_receipt_id) as receipt_id,
iif(ReceiptYesNo IS NOT NULL, iif(ReceiptYesNo=1,1,2), "NULL") AS receipt_idi started from this, which it was working fine and addedFinancesMemoin the code in order to get the correct result