Results 1 to 8 of 8
  1. #1
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142

    Compound IF trouble #error

    I have a field that contains the finish position of a horse race [FinalCall]

    I have a field that contains the winning margin [FinalCallLenAdj]

    I have a fields that defines a "big win" [adjbigwin]


    Anyone see anything wrong with is statement?

    bigwin: IIf(([FinalCall]=1) And ([FinalCallLenAdj]>[adjbigwin]),3,0)


    If the finish position is =1 and the winning margin is greater than the big win definition, I want to return a value of 3, otherwise return zero.

    Whenever the finish position is = 1 it's returning #error and the rest of the time it's returning a zero.



    Thanks

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Seems like your are using field names that execute an agg calc. You will need to include the results of the calculation in your IIf or include the function that is the agg calc in your IIf.

    It is likely the field names, by themselves, are not anything. They are empty.

  3. #3
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    That's not it. Each of those fields is available in one of two different tables that are both input to this query and will always have a value.

    Talking out loud here. Could it be that one of them is not defined as numeric even though it has numeric values in it and that's screwing up the ">" comparison?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You can use the greater than operator as comparison of Text fields, but it may not give you the results expected if you are comparing anything other than Null or an empty string.

  5. #5
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    Hmmmn, then I don't know what the problem could be. :-(

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by wcrimi View Post
    Hmmmn, then I don't know what the problem could be. :-(
    Are you saying the fields are data type text? If there are numbers within a text field you could use the field name as an expression within the CLng() function
    https://msdn.microsoft.com/en-us/lib.../gg278896.aspx

  7. #7
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    I found the problem. [adjbigwin] was defined as a "text" field with values like 4, 3, 2.5, 5.2, etc.... When I changed it to a numeric field with the same values, it worked fine. Sometimes just talking to someone helps. Thank you.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Glad you were able to get it sorted.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Referential Integrity With Compound Index
    By acannon in forum Database Design
    Replies: 9
    Last Post: 06-29-2015, 01:34 PM
  2. Compound in a DLookUp function
    By Lou_Reed in forum Access
    Replies: 7
    Last Post: 05-27-2015, 11:06 AM
  3. Trouble with Compound Query
    By bxdobs in forum Queries
    Replies: 3
    Last Post: 02-20-2015, 11:42 AM
  4. Replies: 3
    Last Post: 03-26-2013, 08:51 AM
  5. Creating Compound summations etc.
    By ohthesilhouettes in forum Queries
    Replies: 2
    Last Post: 06-19-2011, 12:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums