Advanced If

saman

Registered User.
Local time
Today, 03:28
Joined
Dec 30, 2006
Messages
32
hi all
I'm want in a field or text if (alternative 1) where A = 10 and B> = 5 result insert word "a" in C and if is B <5 result insert word "b" in C
and in contain other condition for the next alternatives
for example from attachment picture.
thank.
 

Attachments

  • ABC.JPG
    ABC.JPG
    11.4 KB · Views: 134
I would create a function to get this going, as having it in a single IIF might be complicated.. Copy the code into a standard module, name it randomMod
Code:
Public Function getMyC(tmpA As Long, tmpB As Long) As String
[COLOR=Green]'********************
'Code Courtesy of
'  Paul Eugin
'********************[/COLOR]
    If tmpA = 10 Then
        If tmpB < 5 Then
            getMyC = "b"
        Else
            getMyC = "a"
        End If
    Else
        If tmpB < 3 And tmpB > 5 Then
            getMyC = "b"
        Else
            getMyC = "a"
        End If
    End If
End Function
To use in a Query use it like..
Code:
SELECT A, B, getMyC(A,B) As C
FROM alphabetTable;
 

Users who are viewing this thread

Back
Top Bottom