Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Location
    Richmond, Virginia, USA
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using IIF statement with a crosstab query (2000 SR-1)

    I have an application that is used for tracking employees

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Using IIF statement with a crosstab query (2000 SR-1)

    You could try this:

    WHERE tblTaskNumbers.TaskNumber Like [Forms]![frmReportPrinting]![txtTaskOrderNumber] or Forms]![frmReportPrinting]![txtTaskOrderNumber] is Null

    This has appeared a few times in the last few months in this forum, I think it was MarkD who originally worked this one out.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

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

    Re: Using IIF statement with a crosstab query (2000 SR-1)

    All that creating a parameter does is make the query aware that it needs a value for that parameter. It doesn't mean that the parameter can't be null. See Pat's post. You handle the issue of nulls in the criteria rather than in the parameter. It gets confusing, but the parameter is a property of the query, while the criteria is part of the WHERE or HAVING condition of the SQL.
    Charlotte

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Using IIF statement with a crosstab query (2000 SR-1)

    As Patt suggests you can use OR criteria to test for Null values in query criteria. Also using Nz function would be much simpler than using IIf with IsNull. Instead of:

    Like IIf(IsNull([Forms]![frmReportPrinting]![txtTaskOrderNumber]),"*",[Forms]![frmReportPrinting]![txtTaskOrderNumber])

    I'd use:

    Like Nz(([Forms]![frmReportPrinting]![txtTaskOrderNumber]),"*")

    Explicitly specifying form reference as query parameter is probably best approach, another option would be to wrap expression in Eval function. Example:

    Like Eval("Nz([Forms]![frmReportPrinting]![txtTaskOrderNumber],'*')")

    If you use this expression, when you open 2nd (crosstab) query based on 1st query you will not get the "Jet database engine does not recognize...." msg even though form reference not explicitly specified as a parameter in 1st query. Note use of double quotes around expression to be evaluated by Eval, & single quotes around asterisk. However, if referenced form is not open when either query opened, the Eval function will result in a somewhat cryptic msgbox, as illustrated.

    HTH
    Attached Images Attached Images

  5. #5
    New Lounger
    Join Date
    Aug 2001
    Location
    Richmond, Virginia, USA
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using IIF statement with a crosstab query (2000 SR-1)

    The Like Nz(([Forms]![frmReportPrinting]![txtTaskOrderNumber]),"*") worked like a charm.

    Thanks!!!

    Vernon

Posting Permissions

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