简体   繁体   中英

MS Access excel formula to Access

How do I make this formula work in MS Access 07. I have tried to build it with expression builder but it just gives me the Name error.

=IF(SEX="M",IF(AGE<30,PUSHUPS-20,IF(AGE<40, PUSHUPS -17,IF(AGE<50, PUSHUPS -13,
 IF(AGE<100, PUSHUPS-4,0)))),IF(AGE<30, PUSHUPS -1,IF(AGE<40, 
 PUSHUPS,IF(AGE<50, PUSHUPS +3,IF(AGE<100, PUSHUPS +9,0)))))

Any help would be great, thank you guys. Happy Holiday.

Two options, use IIF or use SWITCH

=IIF(SEX="M",IIF(AGE<30,PUSHUPS-20,IIF(AGE<40, PUSHUPS -17,IIF(AGE<50, PUSHUPS -13, IIF(AGE<100, PUSHUPS-4,0)))),IIF(AGE<30, PUSHUPS -1,IIF(AGE<40,  PUSHUPS,IIF(AGE<50,  PUSHUPS +3,IIF(AGE<100, PUSHUPS +9,0)))))


=iif(SEX="M",Switch(AGE<30, PUSHUPS-20, AGE<40, PUSHUPS -17, AGE<50, PUSHUPS -13, AGE<100, PUSHUPS-4),switch(AGE<30, PUSHUPS -1, AGE<40,  PUSHUPS, AGE<50,  PUSHUPS +3, AGE<100, PUSHUPS +9))

I think Switch is easier to read.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM