Share via

Getting an error in Access query Division by Zero

Anonymous
2014-07-22T18:54:31+00:00

I am trying to divide one field by another in a query.

There are no empty or blank or zeros in the fields I am using.  There are some negative numbers.

The numerator is a dollar amount which can be a negative number

The denominator is a general number and none are zeros.

How can I fix?

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

11 answers

Sort by: Most helpful
  1. Anonymous
    2014-07-22T21:05:11+00:00

    How do you achieve a negative cost/mile?

    Maybe use ---

       Sum([RO Total Cost])/Sum([TotalMiles]) AS Expr1

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2014-07-22T20:54:27+00:00

    No.  It is Currency.  Here is the design view of the table.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2014-07-22T19:38:34+00:00

    Here is the SQL

    SELECT [Trailer Repair Order Detail Report].Trailer, [Trailer Repair Order Detail Report].Mth, [Trailer Repair Order Detail Report].Yr, Sum([Order Data].TotalMiles) AS SumOfTotalMiles, Max([Trailer Repair Order Detail Report].[RO Total Cost]) AS [MaxOfRO Total Cost], Sum([RO Total Cost]/[TotalMiles]) AS Expr1

    FROM [Trailer Repair Order Detail Report] INNER JOIN [Order Data] ON [Trailer Repair Order Detail Report].Trailer = [Order Data].Trailer

    GROUP BY [Trailer Repair Order Detail Report].Trailer, [Trailer Repair Order Detail Report].Mth, [Trailer Repair Order Detail Report].Yr

    HAVING ((([Trailer Repair Order Detail Report].Mth)="May") AND (([Trailer Repair Order Detail Report].Yr)=2014));

    Here is some sample data.  There are no blanks or zeros in either column.

    12001 May 2014 1917 $926.05
    12002 May 2014 2870 $628.03
    12003 May 2014 3145 $855.10
    12004 May 2014 4313 $1.98
    12005 May 2014 4696 ($37.77)
    13001 May 2014 6272 $916.66

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-07-22T19:32:29+00:00

    By correcting the likely error in your query or in your data... which we cannot see. Please post the SQL view of the query and if possible some sample data that triggers the error.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2014-07-22T19:18:12+00:00

    Hi,

    please post we your Sql code.

    Mimmo

    Was this answer helpful?

    0 comments No comments