Solved

Access 2010: Query to concatenate fields with a space

Posted on 2013-12-09
3
622 Views
Last Modified: 2013-12-13
I have a query to concatenate 3 fields "First Initial" + "Middle Initial" + "Last Name".  Sometimes there is no middle initial but I need a space to be in its place but it just joins the “First Initial” + the “Last Name” together.  Any suggestions?
0
Comment
Question by:JAMES125
3 Comments
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 39706947
FirstInitial & IIf(IsNull(MiddleInitial," ', MIddleInitial) & LastName


Kelvin
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39706951
Minor correction to Kelvin's post - no points please.


FirstInitial & IIf(IsNull(MiddleInitial)," ", MIddleInitial) & LastName
0
 
LVL 36

Expert Comment

by:PatHartman
ID: 39707259
The & (ampersand) is the standard VBA concatenation operator and should be used in most cases.  The  + (plus) does double duty as both an arithmetic operator and a concatenation operator but as a concatenation operator, it works differently from the & and it will not work at all as a concatenation operator if the two operands are numeric.  If they are numeric, it will perform its primary function which is to add them.  

The & ignores nulls and the + respects them.  Essentially, the & treats nulls as ZLS,  so

FN & MN & LN will return FNLN if MN is null OR ZLS
BUT
FN + MN + LN will return null if MN (or either of the other two fields) is null OR FNLN if MN is a ZLS.

That tells me that your MN column isn't null but instead contains a ZLS (ZeroLengthString) or you would be asking a different question.  

kevinsparks solution with mbizup's correction of the typo will work.  I just wanted to explain the difference in the way the two operators work since you were using the non-standard one.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

829 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