Expression in a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying have a expression do the following:

If [field name #1] is = 1 or 4 then pull information from [field #2] and if
[field name #1] is = to 2 or 3 then pull information form [field #3]. How
would I write the expression?

Thanks in advance

PJ
 
IIF([field name #1] =1 Or [field name #1] = 4, [field #2], IIF([field name
#1] Between 2 And 3, [field #3],"Error"))

The last part display Error if [field name #1] is not 1, 2, 3, or 4. If
you do not want to display Error the replace it with "" or Null.
 
If the values in field name #1 are 1,2,3,4 only, then try

If ([field name #1] In (1,4),[field #2],[[field #3])
======================================
If there are other values in field 1, then try

If ([field name #1] In (1,4),[field #2],IIf([field name #1] In (2,3),[field
#3],""))
 
Back
Top