• IIF Functions (Access 97)

    Author
    Topic
    #379312

    Every where I look I

    Viewing 0 reply threads
    Author
    Replies
    • #631167

      What context are you using this expression? In a query, on a form or in code?

      • #631172

        This would be a Form or Code

        • #631175

          Try this:
          iif([txtHOLD]=TRUE,”Hold”,iif([txtRENT]=true,”Rent”,””))
          The falsepart can be another if statement. The falsepart of your last if statement would contain the “”
          Scott

        • #631179

          If you’re doing this in Code, you should probably use a standard IF statement in the appropriate event (such as OnChange() or OnCurrent()):

          If chkHold AND NOT chkRent Then
            txtResult  = "Item on HOLD"
          Elseif NOT chkHold AND chkRent Then
            txtResult  = "Item on Rent"
          Else
            txtResult  = ""
          End If

          Hope this helps

        • #631320

          IIF statements are really designed for queries. The IF-End IF and SELECT CASE structures available in code are vastly preferable and much easier to disentangle than nested IIFs. Don’t be persuaded that it’s better to have everything on a single line. It buys you virtually nothing in modern programming languages and makes code much harder to maintain.

    Viewing 0 reply threads
    Reply To: IIF Functions (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: