How do I hide a field if it equals zero in a .mdb form?

R

ricker alford

On a .mdb form I wish to keep fields that result in zero from showing and
being printed on the record. Wayne Morgan helped me solve another problem
with zeros yesterday. Thanks.
 
O

Ofer

On the on current event of the form enter the code that check if the value of
the field = 0 then visible = False

Me.FieldName.visible = (me.FieldName=0)
============================
or you can use

If me.fieldName = 0 then
me.fieldname.visible=false
else
me.fieldname.visible=true
end if
=============================
 
O

Ofer

Sorry, but about this line
Me.FieldName.visible = (me.FieldName=0)

It should be
Me.FieldName.visible = (me.FieldName>0)
 
S

SAm

if your form is based on a query, you can enter the >0 in the criteria of the
query.

sam
 
R

ricker alford

I will try it. Ricker Alford

Ofer said:
On the on current event of the form enter the code that check if the value of
the field = 0 then visible = False

Me.FieldName.visible = (me.FieldName=0)
============================
or you can use

If me.fieldName = 0 then
me.fieldname.visible=false
else
me.fieldname.visible=true
end if
=============================
 
K

Kathy Jacobs

Mine is based on a query but when I put >0 in the criteria it gets rid of the
entire record since the first field in that record is a "zero"...
 
G

George Nicholson

Me.FieldName.visible = (me.FieldName>0)

You took it out of context. It isn't meant to be a query criteria.

That line should go in the Form_Current event, to turn that specific
control/field invisible if its value is zero (and back again when it is
not). In a Report, the line would most likely go in the Detail_Format event
(or the Format event of the appropriate Report section).
 
Top