Calculated field in a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

It's actually Excel/MS query, but it's the same query engine -
Query tries to calculate data from two tables:

table1.sales / table2.units as UnitPrice

table2.units is 0 sometimes which causes a divide by 0 error and query
doesn't run. Any suggestions to run the query returning 0 or blank or error
instead of having the query abort ?

Thanks.
 
It's actually Excel/MS query, but it's the same query engine -
Query tries to calculate data from two tables:

table1.sales / table2.units as UnitPrice

table2.units is 0 sometimes which causes a divide by 0 error and query
doesn't run. Any suggestions to run the query returning 0 or blank or error
instead of having the query abort ?

Thanks.

IIF(table2.units = 0, 0, table1.sales/table2.units)


John W. Vinson[MVP]
 
This is MS Access, a relational database group, not MS Query.

Have you tried an IF statement for the table2.units - 0 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top