The expression is typed incorrectly.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • heathdotnet
    New Member
    • May 2010
    • 4

    #1

    The expression is typed incorrectly.

    I have a db with a bit of yes/no/na drop downs. I have those drop downs pulled into queries to produce the % for each of the records. Everything is fine and dandy till I try to pull a report that has a "N/A" as an answer in the table. It then gives me this error "This expression is typed incorrectly, or is to complex to evaluated...bla h blah blah"

    I gather my numbers for "Yes" with this expression:
    Code:
    CfsQ1_Yes: Switch(tbl_Data!CfsQ1="Yes",1,tbl_Data!CfsQ1="No",0,tbl_Data!CfsQ1="N/A",0)
    My numbers for No/na are gathered together as "opportunit ies" and here is that expression.
    Code:
    CfsQ1_Ops: Switch(tbl_Data!CfsQ1="Yes",1,tbl_Data!CfsQ1="No",1,tbl_Data!CfsQ1="N/A",0)
    Then I have 2 respective queries to take the Sums and finally a query that out puts my final %. My final query that outputs my % looks like this.
    Code:
    CfsQ1: FormatPercent(qry_SumOfQ_Yes_Count!SumOfCfsQ1_Yes/qry_SumOfQ_Ops_Count!SumOfCfsQ1_Ops,2)
    Soooooooooo.... .in a nutshell. 2 qrys to turn my yes/no/na's to numbers. 2 qrys to add them. one qry to output my %. If you're tracking so far, my question is. Why won't my report run with a N/A as a selection? It works perfectly with yes/no in the table. As soon as the n/a is saved in the table....it hacks up.

    Thank you graciously
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    It may be a good idea to separate the functions to see what's working and what isn't. Do the individual queries work before you try to open the report?

    Comment

    • ChipR
      Recognized Expert Top Contributor
      • Jul 2008
      • 1289

      #3
      Also, what is the actual type of the field you are operating on? A text field where you only allow "Yes", "No", "N/A"? This error may be the result of mixing types or trying to operate on null values.

      Your second bit of code counts "Yes" and "No" as 1. Is this intentional?

      Are you trying to print a ratio or a percentage of the total? Either way, you must avoid dividing by zero.

      Comment

      • heathdotnet
        New Member
        • May 2010
        • 4

        #4
        Originally posted by ChipR
        Also, what is the actual type of the field you are operating on? A text field where you only allow "Yes", "No", "N/A"? This error may be the result of mixing types or trying to operate on null values.

        Your second bit of code counts "Yes" and "No" as 1. Is this intentional?

        Are you trying to print a ratio or a percentage of the total? Either way, you must avoid dividing by zero.
        The yes/no/na are a drop down menu. And yes it is intentional that way it can do the math when the yes and the ops are calculated. I've narrowed it down to my final query though. All my other querys work out fine with the n/a value.

        Here is my code again for the final query.
        Code:
        CfsQ1: FormatPercent(qry_SumOfQ_Yes_Count!SumOfCfsQ1_Yes/qry_SumOfQ_Ops_Count!SumOfCfsQ1_Ops,2)
        Can't pinpoint why my troubles are.

        Comment

        • ChipR
          Recognized Expert Top Contributor
          • Jul 2008
          • 1289

          #5
          It sounds like the field in your table is set to use a Display Control of Combo Box. What is the data type for your field, and what is the source for the Combo Box values?

          Comment

          • heathdotnet
            New Member
            • May 2010
            • 4

            #6
            Originally posted by ChipR
            It sounds like the field in your table is set to use a Display Control of Combo Box. What is the data type for your field, and what is the source for the Combo Box values?
            All of my yes/no/na are combo boxes and are set as "text" in the data field. Right now I am retracing my steps to see if I left anything out or possibly have a wondering char. somewhere. I've went back in to previous db's that use the same priciple to see if I have slipped up somewhere. Only conclusion thus far is my n/a's aren't poducing a 0 somewhere and it's kicking back as Null

            Comment

            • ChipR
              Recognized Expert Top Contributor
              • Jul 2008
              • 1289

              #7
              Just to double check,
              qry_SumOfQ_Ops_ Count!SumOfCfsQ 1_Ops
              is not in any case equal to zero?

              Comment

              • heathdotnet
                New Member
                • May 2010
                • 4

                #8
                Originally posted by ChipR
                Just to double check,
                qry_SumOfQ_Ops_ Count!SumOfCfsQ 1_Ops
                is not in any case equal to zero?
                Geeeeeeeeze.... ...I can't believe I missed this. I had a stray field in my last qry that produced my percentages with an expression not pointing to anything. I must have gotten in a rush doing this. That you so much for your time Sir, it is greatly appreciated!

                Comment

                Working...