Urgent Help Required (Reports)

R

Robbyp2001

In my database there are 2 fields that are populated only by a limited number
of records. All the others are blank. On my report there is an area with
the headings 'PE Practical' and 'PE Theory'. What I would like to do is have
this box populated only when there is a value e.g 'PE Practical = 70' but
completely blank when there is no value. I have created a text box on the
report with SQL ="PE Practical" & " " & [PE Practical]. This works but the
headings remain even when the record is blank.

How do I get the report to show no headings when the record has no value and
headings when it has a value?
 
D

Douglas J. Steele

See whether ="PE Practical " + [PE Practical] works any better.

This takes advantage of the fact that + propagates Nulls, while & doesn't
(in other words, "asd" & Null is "asd", while "asd" + Null is Null)
 
R

Robbyp2001

Many thanks Douglas. As usual the simple solutiuon is the best solution. It
works a treat.

Rob

Douglas J. Steele said:
See whether ="PE Practical " + [PE Practical] works any better.

This takes advantage of the fact that + propagates Nulls, while & doesn't
(in other words, "asd" & Null is "asd", while "asd" + Null is Null)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Robbyp2001 said:
In my database there are 2 fields that are populated only by a limited
number
of records. All the others are blank. On my report there is an area with
the headings 'PE Practical' and 'PE Theory'. What I would like to do is
have
this box populated only when there is a value e.g 'PE Practical = 70' but
completely blank when there is no value. I have created a text box on the
report with SQL ="PE Practical" & " " & [PE Practical]. This works but
the
headings remain even when the record is blank.

How do I get the report to show no headings when the record has no value
and
headings when it has a value?
 
P

Peter K

Write in your report test box:
=iif([PE Practical]<>null, "PE Practical "&[PE Practical],null)
 
D

Douglas J. Steele

Due to its nature, you cannot use typical comparison operators on Null: Null
does not equal Null (i.e.: Null = Null will never be True)

You need to use the IsNull function:

=IIf(IsNull([PE Practical]), Null, "PE Practical = " & [PE Practical])

However, in this case, you can take advantage of the fact that +, when used
as a concatenation operator, propagates Nulls (while & doesn't).

That means

="Pe Practical = " + [PE Practical]

will actually do exactly what's being asked for.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Peter K said:
Write in your report test box:
=iif([PE Practical]<>null, "PE Practical "&[PE Practical],null)



Robbyp2001 said:
In my database there are 2 fields that are populated only by a limited
number
of records. All the others are blank. On my report there is an area
with
the headings 'PE Practical' and 'PE Theory'. What I would like to do is
have
this box populated only when there is a value e.g 'PE Practical = 70' but
completely blank when there is no value. I have created a text box on
the
report with SQL ="PE Practical" & " " & [PE Practical]. This works but
the
headings remain even when the record is blank.

How do I get the report to show no headings when the record has no value
and
headings when it has a value?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top