text box and label control sources and concatenation

G

Guest

I have a text box with this control source:

Gross Weight: [tblFGPhysicalAttributes].[GrossWeight] & " " &
[tblFGPhysicalAttributes].[GWUOM]

I use another text box as a label that has this control source:

="Gross Wt: "+IIf(IsNull([Gross Weight]),Null,"")

The problem is that the label appears even if the GrossWeight value is null.

Why is that? I use similar control source code for so many other things
without fault. Is it because the text box control source is concatenating?

THANKS!
 
A

Allen Browne

The expression:
[tblFGPhysicalAttributes].[GrossWeight] & " " &
[tblFGPhysicalAttributes].[GWUOM]
will never be null. It will always contain at least a space.

Try removing the space like this:
Trim([tblFGPhysicalAttributes].[GrossWeight] & " " &
[tblFGPhysicalAttributes].[GWUOM])

For the quazi-label text box, use:
=IIf([Gross Weight] Is Null, Null, "Gross Wt:")
 
G

Guest

Thank you, Mr. Browne! I recall seeing "Trim" in other posts I've perused but
never had a reason to use it until now so it didn't ring a bell. Thanks for
helping me start off my day with a 'ding'

:)

--
www.Marzetti.com


Allen Browne said:
The expression:
[tblFGPhysicalAttributes].[GrossWeight] & " " &
[tblFGPhysicalAttributes].[GWUOM]
will never be null. It will always contain at least a space.

Try removing the space like this:
Trim([tblFGPhysicalAttributes].[GrossWeight] & " " &
[tblFGPhysicalAttributes].[GWUOM])

For the quazi-label text box, use:
=IIf([Gross Weight] Is Null, Null, "Gross Wt:")

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

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

JohnLute said:
I have a text box with this control source:

Gross Weight: [tblFGPhysicalAttributes].[GrossWeight] & " " &
[tblFGPhysicalAttributes].[GWUOM]

I use another text box as a label that has this control source:

="Gross Wt: "+IIf(IsNull([Gross Weight]),Null,"")

The problem is that the label appears even if the GrossWeight value is
null.

Why is that? I use similar control source code for so many other things
without fault. Is it because the text box control source is concatenating?
 

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