Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    #Error in Query (2002)

    Hi,

    I have a query that I'm using to find the % achieved between fields in two queries. The calculations are correct with the exception of when the fields in the 2 queries = 0. In those instances the returned result is #Error. I need for it to simply be zero. This sql returns #error. Is there a way to write the formula so that it will return Zero? I've tried IIF statements and NZ statements but nothing has worked. This is the code before adding anything to it to try to adjust for the #Error result.

    Thanks,
    Leesha

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: #Error in Query (2002)

    You didn't provide any code so I don't know your field names.

    The problem arises because you can't divide by Zero, so we need to test for the denominator being zero.

    <pre>PercentF: IIF([f2]<>0,[f1]/[f2],0)</pre>

    Regards
    John



  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: #Error in Query (2002)

    Hi John,

    Sorry, I thought I posted the code. Your example helped and worked! I was putting quotes around the 0 and that was messing up my iff statement..

    Thanks again,
    Leesha

Posting Permissions

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