default values for queries

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

I cannot find a way to assign a default value in a query
or for a report generated from the query. I am trying to
generate an equipment profit report showing the income,
expenses, and gross profit by equipment. I need month,
year, and life-to-date totals. My problem is if there is
no repair detail yet on a new piece of equipment, that
field is NULL. If it's Null, then my GP will not
calculate. Same is true if a new piece of equipment
hasn't yet generated income, I have blanks in income and
gp. I want a default of 0 if there is no detail to
summarize for that field. Any ideas?
thanks,
-mike
 
Use Nz() to tell Access to use a zero for null.

In SQL View (view menu), this would look something like this:
SELECT Sum([MyField]) As SumOfMyField, ...
so change it to:
SELECT Nz(Sum([MyField]),0) As SumOfMyField, ...
 
ooh I cound kiss you Allen

Why oh why have they changed from the usual COALESCE
function?

oh well, it all works now thatnks to you!

-----Original Message-----
Use Nz() to tell Access to use a zero for null.

In SQL View (view menu), this would look something like this:
SELECT Sum([MyField]) As SumOfMyField, ...
so change it to:
SELECT Nz(Sum([MyField]),0) As SumOfMyField, ...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I cannot find a way to assign a default value in a query
or for a report generated from the query. I am trying to
generate an equipment profit report showing the income,
expenses, and gross profit by equipment. I need month,
year, and life-to-date totals. My problem is if there is
no repair detail yet on a new piece of equipment, that
field is NULL. If it's Null, then my GP will not
calculate. Same is true if a new piece of equipment
hasn't yet generated income, I have blanks in income and
gp. I want a default of 0 if there is no detail to
summarize for that field. Any ideas?
thanks,
-mike


.
 

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

Similar Threads

Another most-recent date query 0
Query Help 5
Query for multiple due dates 8
Need null values for several fields in db 1
NZ in a Count Query 3
Nulls in Joins 2
Nested or Sub query? 2
I'm out of ideas. Help please 1

Back
Top