View Single Post
  #7  
Old June 3rd, 2010, 09:30 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default Firstname plus Middlename??

Steve,
You have made an error in your expression.

" " & MiddleName will always return at least a space.
The plus sign will see the space and return it.

If you wanted to be safe you could use
[surname] & ", " & [firstname] & (" " + [middlename])

Although you could still end up with extra spaces if firstName and middlename
are null you would end up with
Spencer, and a space. "Spencer, "


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Steve wrote:
Duane's expression will give a space after the name if there is no middle
name. The expression should be:
=[surname] & ", " & [firstname] + (" " & [middlename])

When the plus sign is followed by parantheses, if anything is null inside
the parantheses the whole value inside the parantheses becomes null. Thus,
if there is no middle name, the string ends at firstname and there is no
trailing space.

Steve


"Duane Hookom" wrote in message
...
Try
=[surname] & ", " & [firstname] & " " + [middlename]

--
Duane Hookom
Microsoft Access MVP

NOTE: These public News Groups are ending June 1st. Consider asking
questions at
http://social.answers.microsoft.com/...ddbuz/threads?


"KG" wrote:

Apologies if this is a silly question. I'm trying to combine Lastname,
Firstname Middlename in a report. I have
=([surname]+", "+[firstname]+" "+[middlename]).
The only time it works is if all three fields contain values. As the
majority of players don't have middle names in the database, most of the
report is blank.
Can anyone tell me what I'm doing wrong?
Thanks so much for your help.
Kind regards...