Rogue "Divide By Zero" error in 8.5
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Rogue "Divide By Zero" error in 8.5

Hybrid View

  1. #1

    Question Rogue "Divide By Zero" error in 8.5

    I have a report that is throwing a "Cannot Divide By Zero" error. I cannot for the life of me figure out what is in the data that is causing this. I have modified every formula that I can find to account for 0s as well. Is there an easy way to track down where this error is coming from? I'm fairly new to Crystal Reports...

  2. #2
    Join Date
    Jul 2005
    Posts
    1,074

    Re: Rogue "Divide By Zero" error in 8.5

    Welcome to CodeGuru forums!

    One way to protect every division is in the next example
    Code:
    If {TableN.Quantity} <> 0 Then {TableN.Amount} / {TableN.Quantity} Else 0
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3

    Re: Rogue "Divide By Zero" error in 8.5

    Quote Originally Posted by jggtz View Post
    Welcome to CodeGuru forums!

    One way to protect every division is in the next example
    Code:
    If {TableN.Quantity} <> 0 Then {TableN.Amount} / {TableN.Quantity} Else 0
    I have put that If-Then statement around every place that I can find where I am doing division and I'm still getting it.

  4. #4
    Join Date
    Jul 2005
    Posts
    1,074

    Re: Rogue "Divide By Zero" error in 8.5

    In Crystal Reports ide, load the problematic report
    click over Export button
    >>Select "Report Definition"
    >>Select "Disk File"
    >>Click OK
    It generate a txt file with all the report features... maybe it can help
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  5. #5

    Re: Rogue "Divide By Zero" error in 8.5

    Quote Originally Posted by jggtz View Post
    In Crystal Reports ide, load the problematic report
    click over Export button
    >>Select "Report Definition"
    >>Select "Disk File"
    >>Click OK
    It generate a txt file with all the report features... maybe it can help
    Thanks! That was a huge help. I just reviewed the file and every one of my formulas that are doing division look like this...

    if tonumber({REPORT.LBS_TOTAL}) > 0 then
    tonumber({REPORT.GAL}) * tonumber({REPORT.LBS_PER_LOAD}) / tonumber({REPORT.LBS_TOTAL})
    else
    0

  6. #6

    Re: Rogue "Divide By Zero" error in 8.5

    How do I find out what the current database driver is? It looks like I need to change the driver, but I need to know what it currently is so I can change it back.

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center