Make report NOT show Zero values line and shrink

I have a report that has 4 number values horizontally for one detail record.  If all 4 values are ZERO I want to hide the line of detail and shrink the report so it looks as though the detail line was never there.  I think I may have posted this topic before but I can't find it.

Anyway, how can this happen?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
hi Steve,

one way to make this happen is to eliminate rows from the record source unless they have a non-zero value.  You can use criteria such as:

field --> nz([MyFieldname],0)
criteria --> <> 0
show --> No

add additional fields to the grid.  To get all rows where one or more of the values is not zero, put criteria on separate rows so OR is used to combine them.  Field1<>0 or field2 <> 0 or Field3 <>0 or Field4 <> 0  ... so if any values are <> 0, the whole record will show.

have an awesome day,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If the values were null rather than zero, you could suppress printing by using property settings (can grow, can shrink on the controls and on the section) but 0 is a value so you have to do it with code in the Detail section's on Format event or by modifying the query as Crystal suggested.  Personally, I would use the query method.
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
adding on to what Pat said:

My first thought was conversion to null for values in the record source with intention of explaining grow/shrink, and other related information ... but then realized there might be other data (I can't see what you have). Generally, the best way to eliminate what you never want is to make sure that record never gets there ... go for the root. That is better for performance -- and seeing controls at a readable height when you look at the design of the report too.

however, I am curious ... what do the numbers represent?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Dale FyeOwner, Developing Solutions LLCCommented:
Agree with Pat and Crystal that the best way is to exclude them from the recordset in the first place.  Rather than 4 separate criteria, you might try:
WHERE ABS(NZ([Field1], 0)) + ABS(NZ([Field2], 0)) + ABS(NZ([Field3], 0)) + ABS(NZ([Field4], 0)) > 0

Open in new window

I used the ABS function in here because you didn't specify whether all the numbers are positive, and I didn't want to of the values to offset each other.  If all of the number are either zero or > 0 then you can remove the ABS( ) function calls from this line.  BTW, because these might be double precision numbers and the sum of all those columns could be very small, you might want to change the criteria to something like.
WHERE ABS(NZ([Field1], 0)) + ABS(NZ([Field2], 0)) + ABS(NZ([Field3], 0)) + ABS(NZ([Field4], 0)) > 0.000001

Open in new window

SteveL13Author Commented:

Crystal.  I had tried to removed them in the query but ran into trouble.  The query has 4 expressions.  Each of them are a calculation based on a form's fields.  I tried to step them down like this:
but everytime I changed one of the expressions, the <>0's jumped around.  Have you ever seen this before?

Pat.  I ended up doing the onformat "thing" and it worked.

Dale.  I'll try your solution next.
Good thing I mentioned the on Format event as an after thought.  The query should have worked and should have been easier although sometimes creating queries with complex criteria can be a challenge.
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
hi Steve,

glad you got your desired results ~ happy to help

> "ran into trouble ... step them down like this" <

not sure what is really being done and where, but it doesn't look right ... here is an example: Access Query Design - 4 rows of criteria OR Note how the criteria, <>0, is each on its own row. Realize that Nulls will still be allowed -- so the field expressions need to use NZ or something else to ensure there is always a value. Num123 could be Null if Num3 is Null even when Num12 has a value. If either Num1 or Num2 is null, Num12 will be 0 since NZ is wrapped around the entire expression. Alternately, Num12 could be Nz(Num1,0) + NZ(Num2,0) ... depends if you really want a result if one of the factors is missing

If you have other criteria that needs to apply to each case as well, it needs to be repeated on each row.

and notice also, how you can use a calculated field name in another field expression (Num123) ...

have an awesome day,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.