Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding value 0 in report

Status
Not open for further replies.

mfd777

Programmer
Sep 21, 1999
53
IE
I have a query which has a number of text and number fields. I am basing a report on the query. A few of the numberfields are usually 0. I would like the number fields that have a value of 0 to be suppressed on print. I can't filter them out of the query as other fields in the same record need to print.<br>
<br>
Thanks in advance.
 
In the OnPrint event of the Detail Section:<br>
<br>
If Me![fieldname] = &quot;0&quot; Then<br>
Me![fieldname].Visible = False<br>
Else<br>
Me![fieldname].Visible = True<br>
End If<br>

 
If you aren't doing any math calculations on the column, then write a function that accepts the value as a parameter. If the value is zero, return a null. If it is any other value, return the value.<br>
<br>
If you are doing calculations, try returning a space instead of a null.<br>
<br>
The code should look something like this:<br>
<br>
Function ZeroToNull(AnyValue As Variant)<br>
<br>
If AnyValue = 0 Then<br>
ZeroToNull = Null<br>
Else<br>
ZeroToNull = AnyValue<br>
End If<br>
<br>
End Function<br>
<br>
<br>
Replace = Null with = &quot; &quot; if you use the column in calculations because a NULL will not calculate properly.<br>
<br>
Your calling query should like something like this:<br>
NewVal:ZeroToNull(OrgVal)<br>
<br>
<br>
Good luck
 
I should've warned you that making the field invisible is <b>not</b> pretty if you have a border, backgound, <span style=color:red>color</span> etc. in that field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top