0 values in a report

  • Thread starter Thread starter fanor
  • Start date Start date
F

fanor

Hi all,

I have a numeric field in a report, but when its value is 0 I don't want
to be printed, how can i get that?? i tried to use IIF, but for some
reason i got #Error

IIF([myfield]=0,"",str([myfield]))


my field is not an ACCESS reserved word

thaks so much guys
 
Hi all,

I have a numeric field in a report, but when its value is 0 I don't want
to be printed, how can i get that?? i tried to use IIF, but for some
reason i got #Error

IIF([myfield]=0,"",str([myfield]))

my field is not an ACCESS reserved word

thaks so much guys

You probably got an error because the name of the control is
"MyField".
The name of a calculated control cannot be the same as the name of a
field used in it's control source expression. Change the name of the
control to something else, perhaps txtMyField.

Also, if the only thing you wish to do is not display the zero, you
can simply use a regular control bound to MyField instead of one using
an expression.
Set it's Format property to
#,-#

Only positive or negative numbers will display. Nothing will display
if the field is Zero.
 
Hi all,

I have a numeric field in a report, but when its value is 0 I don't want
to be printed, how can i get that?? i tried to use IIF, but for some
reason i got #Error

IIF([myfield]=0,"",str([myfield]))


my field is not an ACCESS reserved word

thaks so much guys
Any possibility that "myfield" could be null? You might test for that.

IIf(Nz([myfield],0) = 0, "", Str([myfield]))

Some other thoughts:
If you don't really want the "field" (they are actually called
controls) to be printed then you can test it in the sections On Format
event.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Me.myfield.Visible = Nz(Me.myfield) > 0
End Sub

That would accomplish the same thing without an IIf expression.

Good Luck,
- Jim
 
thanks so much guys,
As Fred said the problem with IIF was that the control name was the
same as the field name like
 
Back
Top