Solved

Trim Envelope Labels

Posted on 2004-09-23
5
273 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
  • 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 125 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

861 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