Nested If

K

Ken@AP&T

I am using Access 2000. I am trying to create a macro to set a value of a
form field (AmtDue) based upon one of five nested conditions:

1) If CodeFieldA = "S" or "M", then AmtDue = 0
Else
2) If CodeFieldB Like "RB*, then AmtDue = 0
Else
3) If RateFieldA > RateFieldB then AmtDue = RateFieldA - RateFieldB
Else
4) If RateFieldA < RateFieldB then AmtDue = RateFieldA
Else
5) If RateFieldA = RateFieldB then AmtDue = RateFieldB.

Each subsequent test is based upon a False condition on the prior condition,
the last condition RateFieldA = RateFieldB is the default.

How do I code this?
 
D

Douglas J. Steele

Already answered in another newsgroup to which you posted the same question.

If you feel you need to post to more than one group (HINT: it's seldom
necessary), please have the courtesy to cross-post (send the one message to
all groups at once), rather than multi-post (send individual messages to
each group). In this way, all responses to your post will be available
together, regardless of what group the responder was in, and the rest of us
won't have to read your post multiple times. (It also uses fewer server
resources)

If you're using Microsoft's web interface to post, I believe that you can
type the names of the various groups into the Newsgroup box. Separate each
newsgroup name with a semicolon.

Note that it's generally consider to be A Bad Thing to cross-post to more
than about 2 or 3 newsgroups. (In fact, at
http://www.microsoft.com/presspass/features/2001/Mar01/Mar27pmvp.asp
Microsoft suggests that "One group will suffice")
 
K

Ken@AP&T

Thanks for the tips. Being new to the group I wasn't fully clear on the
cros-posting procedures (i.e. using the semicolon). As to the need for
cross-posting, I wasn't sure which group the question applied to.
 
L

Lesley Reeves-Hunt

Could you direct me to the answer....this question is very similar to the one
I was going to ask. Thanks
 
K

Ken@AP&T

Here's the code I used: =Switch([ClassCode]="B" Or
[ClassCode]="S",0,[CoverageCode] Like "RB*",[AUG Class
Rate],[CoverageCode]="FREE",0,[AUG Provider Rate]>[AUG Class Rate],[AUG
Provider Rate]-[AUG Class Rate],[AUG Provider Rate]<[AUG Class Rate],[AUG
Provider Rate],[AUG Provider Rate]=[AUG Class Rate],[AUG Class Rate])
 
Top