Label not visible if data are missing

  • Thread starter Thread starter Marc
  • Start date Start date
M

Marc

Dear All,

in a report, if I have an empty field, such as Fao (for the attention of)
how can I hide its label? And show it if datum is present?

Thanks in advance,

Marc
 
In report design view, right-click the label and:
Change To | Text Box.

Set the ControlSource of the new text box to:
=IIf([Fao] Is Null, Null, "Fao")
 
Or set the control source of the text box to
="Fao " + [Fao]
Don't allow the text box to grow.

--
Duane Hookom
MS Access MVP
--

Allen Browne said:
In report design view, right-click the label and:
Change To | Text Box.

Set the ControlSource of the new text box to:
=IIf([Fao] Is Null, Null, "Fao")

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

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

Marc said:
in a report, if I have an empty field, such as Fao (for the attention of)
how can I hide its label? And show it if datum is present?
 
In report design view, right-click the label and:
Change To | Text Box.

Set the ControlSource of the new text box to:
=IIf([Fao] Is Null, Null, "Fao")
Allen


Hi Allen,
thank you for your prompt answer, the code, you gave me, is similar the
conditional functions in excel.

I followed your tip, I changed the label in a text box but when I run the
report from a form, it gives this kind of message:
Error 3075 Sintax error (coma) in the query expression '[
=IIf([Fao] Is Null, Null, "Fao")

=IIf([Fao] Is Null, Null, "Fao")
]'

and unfortunately I don't know what it means or I don't know how to solve
this popup message.

Anyway thanks again for your help.
Kind regards,
Marc
 
Not sure I follow what happened. The idea was to type the expression:
=IIf([Fao] Is Null, Null, "Fao")
beside the Control Source property in the Properties box.

The syntax error suggests that it went into a code window somewhere?

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

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

Marc said:
In report design view, right-click the label and:
Change To | Text Box.

Set the ControlSource of the new text box to:
=IIf([Fao] Is Null, Null, "Fao")
Allen


Hi Allen,
thank you for your prompt answer, the code, you gave me, is similar the
conditional functions in excel.

I followed your tip, I changed the label in a text box but when I run the
report from a form, it gives this kind of message:
Error 3075 Sintax error (coma) in the query expression '[
=IIf([Fao] Is Null, Null, "Fao")

=IIf([Fao] Is Null, Null, "Fao")
]'

and unfortunately I don't know what it means or I don't know how to solve
this popup message.

Anyway thanks again for your help.
Kind regards,
Marc
 
Allen Browne said:
Not sure I follow what happened. The idea was to type the expression:
=IIf([Fao] Is Null, Null, "Fao")
beside the Control Source property in the Properties box.

The syntax error suggests that it went into a code window somewhere?

Hi Allen,
thanks for your tip, don't worry if the code, at the moment, doesn't
work. Your advice is useful, because now I know in which direction I can
research & develop the solution of the problem by myself.
Thank you very much for your help.
Kind regards,
Marc
 
Allen: PMFJI, but shouldn't that be =IIf(IsNull([Fao]), Null, "Fao") ? I
thought Is Null only worked in SQL statements.

But what's the point of that statement? What does that do differently than
just using [Fao] as the Control Source?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Allen Browne said:
Not sure I follow what happened. The idea was to type the expression:
=IIf([Fao] Is Null, Null, "Fao")
beside the Control Source property in the Properties box.

The syntax error suggests that it went into a code window somewhere?

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

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

Marc said:
In report design view, right-click the label and:
Change To | Text Box.

Set the ControlSource of the new text box to:
=IIf([Fao] Is Null, Null, "Fao")
Allen


Hi Allen,
thank you for your prompt answer, the code, you gave me, is similar the
conditional functions in excel.

I followed your tip, I changed the label in a text box but when I run the
report from a form, it gives this kind of message:
Error 3075 Sintax error (coma) in the query expression '[
=IIf([Fao] Is Null, Null, "Fao")

=IIf([Fao] Is Null, Null, "Fao")
]'

and unfortunately I don't know what it means or I don't know how to solve
this popup message.

Anyway thanks again for your help.
Kind regards,
Marc
 
I think you will find Is Null is interpreted okay in the context of a
Control Source. Where possible I do prefer that to using IsNull(), to avoid
the extra function call.

This text box is a quazi-label for the Fao field. If the field Fao is not
null, it returns the literal text Fao, i.e. it acts as a label. The point of
making it Null when Fao is null is that the text box Can Shrink. So if Fao
is null, both the text box and its quazi-label shrink, allowing the entire
line to disappear from the report. If you use a label as normal, the Caption
of the label prints on the line, so it will not shrink.

Please do post back if I am missing something here.
 
Ah. My fault. I missed the quotes around "Fao" in the False part.

Thanks, Allen.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Allen Browne said:
I think you will find Is Null is interpreted okay in the context of a
Control Source. Where possible I do prefer that to using IsNull(), to avoid
the extra function call.

This text box is a quazi-label for the Fao field. If the field Fao is not
null, it returns the literal text Fao, i.e. it acts as a label. The point of
making it Null when Fao is null is that the text box Can Shrink. So if Fao
is null, both the text box and its quazi-label shrink, allowing the entire
line to disappear from the report. If you use a label as normal, the Caption
of the label prints on the line, so it will not shrink.

Please do post back if I am missing something here.

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

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

Douglas J. Steele said:
Allen: PMFJI, but shouldn't that be =IIf(IsNull([Fao]), Null, "Fao") ?
I
thought Is Null only worked in SQL statements.

But what's the point of that statement? What does that do differently than
just using [Fao] as the Control Source?
 
Hi Allen,
I discovered where the piece of code doesn't work. It was a "comma" instead
of a "semicolon".

Exploring the Microsoft Nordwind database, in the "Invoices report" there is
a field with this kind of statement:

=IIf([Zone] Is Null;[DeliveryCity] & " " & [DeliveryZip];[DeliveryCity] & "
" & [DeliveryZone] & " " & [DeliveryZip])

so I changed your statement in

=IIf([Fao] Is Null;Null;"Fao:")

and it works perfectly!!!!!!!

Now I am happy!!!!

I don't know if there is a difference of syntax between the English and the
Italian Access version, anyway thank you very much for you help!!!

Best wishes,
Marc
 
There can be differences between using , and ; depending on the Regional
Settings.
 
Back
Top