Multiple "IIF" statements

C

Cloudbuster

I want to make a column in a query that contains multiple "IIF" statements
using VBA code. I want the column to recognize that if the returned value for
another column is "A", for example, show it as "1", but if the value is "B",
then show a "2", and so on...I have experience using VBA, so an example
script would probably be fine...
 
W

Wayne-I-M

SomeOtherField:
(IIf([SomeField]=1,"A",IIf([SomeField]=2,"B",IIf([SomeField]=3,"C"))))


Or for a form

Private Sub Something_Something
If Me.SomeField = A Then
Me.SomeotherField = 1
If Me.SomeField = B Then
Me.SomeotherField = 2
If Me.SomeField = C Then
Me.SomeotherField = 3
If Me.SomeField = C Then
Me.SomeotherField = 4
End If
End If
End If
End If
 
C

Cloudbuster

Thanks Wayne! Most helpful, and simple!

Wayne-I-M said:
SomeOtherField:
(IIf([SomeField]=1,"A",IIf([SomeField]=2,"B",IIf([SomeField]=3,"C"))))


Or for a form

Private Sub Something_Something
If Me.SomeField = A Then
Me.SomeotherField = 1
If Me.SomeField = B Then
Me.SomeotherField = 2
If Me.SomeField = C Then
Me.SomeotherField = 3
If Me.SomeField = C Then
Me.SomeotherField = 4
End If
End If
End If
End If






--
Wayne
Manchester, England.



Cloudbuster said:
I want to make a column in a query that contains multiple "IIF" statements
using VBA code. I want the column to recognize that if the returned value for
another column is "A", for example, show it as "1", but if the value is "B",
then show a "2", and so on...I have experience using VBA, so an example
script would probably be fine...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top