dvang


I'm making address labels and within the table that I'm using there are 2 address fields called Address1 and Address2. The majority of the records do not use Address2, but some do. Is there an expression in VB that I can write so that if Address2 is blank, it will not show Address2

Here's my snippet so far. It's inside a text box inside a list box in the layout of reporting in visual studio 2005.

Code Snippet

=RTrim(Fields!FirstName.Value) & " " & Fields!LastName.Value & vbCrLF &

Fields!Address1.Value & vbCrLF & Fields!Address2.Value & vbCrLF &

RTrim(Fields!City.Value) & ", " & Fields!State.Value & " " & Fields!ZipCode.Value

This code produces the following if there is no Address2:

John Doe

234 W. Nowhere St.

Seattle, WA 77658

How can I make it so that it will know that Address2 is blank and to return this:

John Doe

234 W. Nowhere St.

Seattle, WA 77658

Any help is greatly appreciated!





Re: How do I not show a field if the field contains nothing?

T Schuller


To account for a null or empty string in address2...

=RTrim(Fields!FirstName.Value) & " " & Fields!LastName.Value & vbCrLF &

Fields!Address1.Value & vbCrLF & IIF(Fields!Address2.Value Is Nothing Or Fields!Address2.Value = "", "", Fields!Address2.Value & vbCrLF) &

RTrim(Fields!City.Value) & ", " & Fields!State.Value & " " & Fields!ZipCode.Value






Re: How do I not show a field if the field contains nothing?

dvang

what does the IS NOTHING code translate to does it mean if the field is blank

if i just use the IS NOTHING code alone without the OR...="", then it works perfect, but should I be concened about not have the OR or second condition in there will the IS NOTHING be enough

thanks for helping! it's working so far, i'm just wondering about future confrontations with this. thanks!







Re: How do I not show a field if the field contains nothing?

BobP - BIM

The IsNothing is to handle NULL fields. The "" takes out the fields that are just blank.

BobP