IIf clause in Access doesn't work correctly

70 Views Asked by At

I'm trying to create a table for invoice in Access and this is my table schema:

id AutoNumber
customer_name Number
product_name Number
count Number
unit Calculated
date Number

The customer name and product name are lookup wizard that select their data from another table. I need the unit automatically select the unit based on product name for example:

"ورق آ۴"

for these unit must fill itself with:

"برگ"

and for these:

"مداد"

must fill itself with:

"عدد"

so I write an expression for this:

IIf([product_name]="برگ","ورق آ۴",IIf([product_name]="عدد","مداد","-"))

but it fills all of the product units with "-". Any solution?

2

There are 2 best solutions below

0
Alora On BEST ANSWER

I try so many solutions but at last I decided to use product_id and work with it it's so simple and Access doesn't need to encode the text in IIf and compare any more!

0
miniek On

This is most likely the encoding issue. You can try:

  • open an editor that can handle encoding - like Notepad++
  • set a new empty file with Unicode ( or UCS-2 )
  • paste your product name
  • convert to UTF-8
  • copy and paste to your Access formula.

Worked for me with your product_name(s)

brgds, m.