423,850 Members | 1,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,850 IT Pros & Developers. It's quick & easy.

If, then, else statements

P: 13
Can someone give some advice? I am not big on VB scripts, so am trying to write an expression in an update query that is designed to populate a field which I will use as the email first letter. If the rank is SC then the prefix is "s", if the rank is "Admin" etc through to "SRO2 then the prefix is "c" otherwise the rank is a police officer and the prefix is "p". The letters s or c or p are entered into the field indicated in the query.

The expression reads

IIf([Workers]![Rank]="SC","s",IIf([Workers]![Rank]="ADMIN" Or "AGENCY" Or "ANALYST" Or "CIV" Or "PHOTOG" Or "SCENE EX" Or "OTHER" Or "CIV SUPV" Or "Cadet" Or "Comms" Or "PCSO" Or "TraffW" Or "SRO","c","p"))

but it doesn't want to work.

Could someone either tell me what is wrong with the expression, or show me a VB alternative that I can use to update all records?

Many thanks,

B
Mar 28 '07 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,279
The problem is with [Workers]![Rank]="ADMIN" Or "AGENCY" Or "ANALYST" and so on.

You have to use either [Workers]![Rank] In("ADMIN", "AGENCY", "ANALYST") or [Workers]![Rank] = "ADMIN" Or [Workers]![Rank] = "AGENCY" and so on.
Mar 28 '07 #2

P: 13
It worked! Had tried In("Etc") before but the syntax was wrong. A million thanks.

B
Mar 29 '07 #3

Rabbit
Expert Mod 10K+
P: 12,279
It worked! Had tried In("Etc") before but the syntax was wrong. A million thanks.

B
Not a problem.
Mar 29 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.