Share via

Div/0 Error In Access

Anonymous
2015-03-26T16:47:24+00:00

I have a form that displays a Div/0 error when one the required fields is left at 0.  The calculation is done in the background query.  Is there a way to have the form display a blank or a N/A when a Div/0 error occurrs?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2015-03-26T17:39:50+00:00

The following should return a zero if Total Hours is zero:

IIF([Total Hours]>0,[Total Quantity]/[Total Hours], 0)

or to return 'N/A':

IIF([Total Hours]>0,[Total Quantity]/[Total Hours],"N/A")

The former might be better if you need to do any further operations on the value e.g. summation over a set of rows in a report.

PS:  The above should work in a query, but not in code.

Was this answer helpful?

5 people found this answer helpful.
0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2017-08-31T21:47:47+00:00

    I am merging an Access DB with word. When I open the Access DB from Word I see the the Access entries are surrounded by <div> and </div>. What's up with this?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-03-26T19:52:54+00:00

    Thanks so much Ken, that did the trick!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2015-03-26T17:24:13+00:00

    Ken:  the expression in the query field is

    Task Productivity Rate: [Total Quantity]/[Total Hours]

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2015-03-26T17:11:21+00:00

    What is the expression in the query?  You should be able to amend it to incorporate an IIF function call so that the division by zero error is avoided.  Or you can write a little function which does the same.

    Was this answer helpful?

    0 comments No comments