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

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Using IIF statement with a crosstab query (2000 SR-1)

    Author
    Topic
    #383025

    I have an application that is used for tracking employees

    Viewing 2 reply threads
    Author
    Replies
    • #651644

      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 smile

    • #651720

      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.

    • #651768

      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

      • #652219

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

        Thanks!!!

        Vernon

    Viewing 2 reply threads
    Reply To: Using IIF statement with a crosstab query (2000 SR-1)

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

    Your information: