Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    146
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IIf statement (2000 SR-1)

    I'm trying to decipher an IIf statement in a database I inherited, and I was wondering if this is correct. I couldn't find a Help file example of this kind of nested IIf statement.

    STATEMENT:

    IIf([SubsID]=99,IIf(Left([ScreenID],2)="AD","CL",Left([ScreenID],2)))

    MY INTERPRETATION:

    If SubsID = 99 Then
    If left two characters of ScreenID = AD Then
    Value = CL
    Else
    Value = Left two characters of ScreenID
    End If
    End If


    Thanks,
    Bob

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: IIf statement (2000 SR-1)

    That would be my interpretation. I shudder to think of what led to this!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: IIf statement (2000 SR-1)

    IIf([SubsID]=99,IIf(Left([ScreenID],2)="AD","CL",Left([ScreenID],2)))

    If [SubsID] = 99 Then
    If left 2 characters of [ScreenID] are "AD" then
    value = "CL"
    Else
    value = left 2 characters of [ScreenID]
    End If
    Else
    ' no value returned
    End If

    There is no provision in this statement for what happens if [SubsID] is not 99, which would be something like this:

    IIf([SubsID]=99,IIf(Left([ScreenID],2)="AD","CL",Left([ScreenID],2)), Left([ScreenID],2))

    This assumes you want to return anything when SubsID <> 99 and that the value should be the left two characters of ScreenID in all cases except where SubsID = 99.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •