Results 1 to 5 of 5
  1. #1
    Huddle is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2010
    Posts
    318

    Formula causing Error due to "-" is there a way around

    I am using the below formula that works if the SumOfSumOfBat_Totals has data, but if it doesn't and puts a dash it causes and error because it is a percentage. The formula works in other areas where it is not a percentage.



    Is there a way to clear the Error with IFERROR or NZ?


    IIf([SumOfSumOfBat_Totals]=0,"-",[Bat_Pct])*1

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Not sure if your error is the result of [Bat_Pct] when SumOfSumOfBat is null or if it's because of the "-". Is this a text field? If not, you can't use -
    try
    IIf(Nz([SumOfSumOfBat_Totals],0)=0,"-",[Bat_Pct])*1
    or
    IIf(Nz([SumOfSumOfBat_Totals],0)=0,0,[Bat_Pct])*1
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    What are you actually trying to achieve? It looks like you want to display a - instead of 0. If that is the case then just use the format property
    Last edited by CJ_London; 12-13-2022 at 05:55 AM.

  4. #4
    Join Date
    Apr 2017
    Posts
    1,679
    Is SumOfSumOfBat_Totals a text field? I assume, it is numeric one. And the result of calculation when source is numeric must be numeric or Null also. Especially when you want to insert the result into some numeric field or control too. Differently of Excel, Field types in Access have much more to say, what you can enter or not.

  5. #5
    Huddle is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2010
    Posts
    318
    OK, Thank you for all your help.

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

Similar Threads

  1. Replies: 5
    Last Post: 04-08-2021, 09:15 AM
  2. How do I track down what's causing this "#Error"?
    By cherold in forum Programming
    Replies: 7
    Last Post: 11-02-2017, 01:11 AM
  3. Replies: 2
    Last Post: 07-14-2014, 10:34 AM
  4. table field name "Year" causing Argument Not Optional
    By JosmithTwo in forum Programming
    Replies: 2
    Last Post: 09-26-2012, 08:01 PM
  5. StrComp causing "Invalid use of Null" error
    By sephiroth2906 in forum Programming
    Replies: 5
    Last Post: 09-15-2011, 07:06 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