?
Solved

Trim Envelope Labels

Posted on 2004-09-23
5
Medium Priority
?
291 Views
Last Modified: 2012-05-05
I am printing a large number of labels with the following format:

[salutation] [first] [init] [last] [suffix]     * suffix example: Jr.,Sr.III
[contact]
[address1]
[address2]
[city] [state] [zip]

The main problem is line 1. [salutation], [suffix] and  Middle name (init) may be a NULL value. I need the proper Trim() procedure.

E.G.  if NOT ISNULL (init) then [first] & " " & [init] & " " & [last] else [first] & " " & [last].   Any help will be appreciated.

David





0
Comment
Question by:DavidDF1913
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:justinbillig
ID: 12139229
try this

init = "" & init

that will cast it to a string so if the value is null it will be an empty string

0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12139596
Something like this:

([Salutation]+" ") & ([First]+" ") & ([Init]+" ") & ([Last]+" ") & [Suffix]

The + operator will yield a null value if the field is null so the space will be ignored. For example, if Init is null, the above evaluates to:
([Salutation]+" ") & ([First]+" ") & Null & ([Last]+" ") & [Suffix]

To clarify that better:
"a"+Null=Null
"a" & Null="a"
0
 

Author Comment

by:DavidDF1913
ID: 12144145
This is a modification to my original question.  Is it possible to do something like this in a single line?

=Trim([Salutation] & " " &  [First] & if not isnull ([init]) then " " & [init] & " " & [Last])

David

0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 total points
ID: 12144287
You could:
=Trim([Salutation] & " " & [First] & IIf(Not IsNull([init])," " & [init],"") & [Last])

Although the line I gave you will also achieve the same effect.
0
 

Author Comment

by:DavidDF1913
ID: 12144978
This worked great!
Trim([Salutation] & " " & [First] & IIf(Not IsNull([init])," " & [init],"") & [Last])

Thanks,

David


0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question