IIf in Expression Builder (1 Viewer)

safril

New member
Local time
Tomorrow, 04:35
Joined
Aug 7, 2021
Messages
14
Hi, i'm newbie in Access. I have a field that contains a list of month names in a year and I want to convert it automatically to roman numerals in another field. I've used the IIf function but it only returns 'XII' for all month names. Am I missed something? This is my Expression Builder syntax:
Code:
IIf([BPerm_Banding]="Januari";"I";IIf([BPerm_Banding]="Februari";"II";IIf([BPerm_Banding]="Maret";"III";IIf([BPerm_Banding]="April";"IV";IIf([BPerm_Banding]="Mei";"V";IIf([BPerm_Banding]="Juni";"VI";IIf([BPerm_Banding]="Juli";"VII";IIf([BPerm_Banding]="Agustus";"VIII";IIf([BPerm_Banding]="September";"IX";IIf([BPerm_Banding]="Oktober";"X";IIf([BPerm_Banding]="November";"XI";"XII")))))))))))
Please help. Thanks in advance 😟
 

moke123

AWF VIP
Local time
Today, 17:35
Joined
Jan 11, 2013
Messages
3,927
What is the datatype of [BPerm_Banding]? Your getting XII because none of the conditions in your expression are being met.
You can probably also use the Switch function.

I'm also not sure if using a comma as opposed to a semi-colon makes a difference. In english versions of access you'd use a comma but some other versions use a semi-colon.
 
Last edited:

plog

Banishment Pending
Local time
Today, 16:35
Joined
May 11, 2011
Messages
11,653
So wait, you have a list of values that you want to relate to another set of values? Like one set of values could be in a vertical list and right next to each value could be a vertical list of the values you want them to relate to?

Perhaps code in Access isn't the way to implement this solution.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:35
Joined
May 7, 2009
Messages
19,247
you can actually build another table with those month and roman numbers:

tblRomanMonth
Month (short string)
Roman (short string)
MonthNum (integer)

MonthRomanMonthNum
JanuariI
1​
FebruariII
2​
MaretIII
3​
AprilIV
4​
MeiV
5​
JuniVI
6​
JuliVII
7​
AgustusVIII
8​
SeptemberIX
9​
OktoberX
10​
NovemberXI
11​
DesemberXII
12​

you can add this Table to your Query:

SELECT yourTable.*, tblRomanMonth.Roman
FROM yourTable
LEFT JOIN
tblRomanMonth ON yourTable.[BPerm_Banding]=tblRomanMonth.Month
 

Users who are viewing this thread

Top Bottom