Why is this Data Mismatch ??? =(

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kwokv616
    New Member
    • Nov 2008
    • 13

    #1

    Why is this Data Mismatch ??? =(

    =( what is wrong with this...
    when i run the query it says "data type mismatch in criteria expression"...


    Field
    aprid: Sum(([prem]+[eprem_o]+[eprem_m])*1*IIf((Not ([code]=[rcode]) And Not ([rcode]=("TOPUP" Or "FSB" Or "FSSB" Or "MKB"))) And ([status]="I" Or ([status]="P" And Not (IsEmpty([edate])))),1,0))
    Total
    Expression

    Field
    apTU: Sum(([prem]+[eprem_o]+[eprem_m])*1*IIf([rcode]=("TOPUP" Or "FSB" Or "FSSB" Or "MKB") And ([status]="I" Or ([status]="P" And Not (IsEmpty([edate])))),1,0))
    Total
    Expression

    Thank you!!
  • mandanarchi
    New Member
    • Sep 2008
    • 90

    #2
    Whenever I get this error it's usually because I've tried linking a text field to a number field or something similar.
    Without knowing more info about your table and/or query I can't help.

    Could you post the (relevant) field names and types?

    Comment

    • Stewart Ross
      Recognized Expert Moderator Specialist
      • Feb 2008
      • 2545

      #3
      An OR has to work on an expression it can evaluate to True or False.

      Your current ORs try to OR string literal values to the statement preceding - not what you meant to write, but that is its effect. This approach, of writing

      a OR b OR c OR d

      could only work if the values a..d being ORd this way are of boolean type (True/False values), not strings. Hence the type mismatch error.

      Personally, I think your approach is so complicated (with far too many comparisons and conditions) I'd rethink this one from scratch. However, if you want to at least fix the syntax errors your ORs should be along these lines:

      Code:
      ... And Not (([rcode]="TOPUP") Or ([rcode]="FSB") Or ([rcode]="FSSB") ...
      -Stewart

      Comment

      Working...