Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Location
    Toronto, Canada
    Posts
    259

    Unanswered: Problem with expression.

    For a query, i have a specific requirement.
    if the agent selected on the form = JoeBloe, (ID = 16), then select all records where he's the agent + where Harry (ID = 1) + where no agent listed (ID=0)

    else, select records where agent = agent selected


    IIf(CInt([Forms]![CriticalDeadlinesReport-By Agent]![Combo0])=16,16 Or 1 Or 0,[Forms]![CriticalDeadlinesReport-By Agent]![Combo0])

    it works for any case except those when i select JoeBloe...then i get 0 results...even though i know there are...

  2. #2
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    syntax error : iff (value, if true this value, if not true this value)

    you can´t use "or" in this statement, only two values.

  3. #3
    Join Date
    Sep 2004
    Posts
    161
    Sory emiel but you can use or in iif expression :

    test = IIf(CInt(toto) = 16 Or CInt(toto) = 1 Or CInt(toto) = 0, "True", "False")

    Jerrie, emiel is right, iif need condition, true part, false part

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    so the same issue is back again

    16 Or 1 Or 0
    bitwise OR evaluates fine...
    = -1
    = accessTRUE
    but that's probably not what you wanted

    why not construct SQL in code somehow along the lines of the previous idea: use your code-SQL to edit a saved qryDef, make a new qryDef, make a temporary qryDef, use as .rowsource, use as .recordsource, or run directly with docmd.runsql

    izy
    currently using SS 2008R2

Posting Permissions

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