IIF statement question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • p543
    New Member
    • Jun 2007
    • 3

    #1

    IIF statement question

    Hi,
    I am using Access 2003 on Windows XP, SP2. I am using the following IIF statement
    Code:
    Shift: IIf([i_timerec] Between 800 And 1559,"Day","Evening/Mids")
    and it is giving me the two returns. I would like to add 1600 and 2359 and a get a return of Evening and 0 to 759 to get a return of Mids. Is it possible to use an IIf statement so that I could get 3 returns, so evening and mids could be seperated as well. If not does anyone know a way to get the result I am looking for. Thanks.
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Originally posted by p543
    Hi,
    I am using Access 2003 on Windows XP, SP2. I am using the following IIF statement
    [CODE]Shift: IIf([i_timerec] Between 800 And 1559,"Day","Eve ning/Mids")[CODE]
    and it is giving me the two returns. I would like to add 1600 and 2359 and a get a return of Evening and 0 to 759 to get a return of Mids. Is it possible to use an IIf statement so that I could get 3 returns, so evening and mids could be seperated as well. If not does anyone know a way to get the result I am looking for. Thanks.
    Use "Switch" function. Function syntax and example you can find in Access help.

    Good luck.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Originally posted by Help
      Switch Function

      Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True.

      Syntax

      Switch(expr-1, value-1[, expr-2, value-2 … [, expr-n,value-n]])

      The Switch function syntax has these parts:

      Part Description
      expr Required. Variant expression you want to evaluate.
      value Required. Value or expression to be returned if the corresponding expression is True.
      This is a decent function to use for your problem. For something as straightforward as this though, some nested IIf()s would work as well (not aswell).
      Code:
      Shift: IIf([i_timerec]<800,"Mids",IIf([i_timerec]<1600,"Day","Evening"))

      Comment

      Working...