473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

String Concatenation

In past versions of Access it was a simple matter to create a persons full
name from the three strings 'FirstName' 'MiddleInit' and 'LastName' and
include a period after the middle initial. Using a plus sign before the
middle initial kept the period from showing up if the middle initial was
blank. Seems Access 2003 doesn't recognize this simple trick.

So the question is, how do create a full name in a query without having a
period show up between FirstName and LastName if there is no middle name?

Thank you
Nov 13 '05 #1
9 2315
Rebecca Smith wrote:
In past versions of Access it was a simple matter to create a persons full
name from the three strings 'FirstName' 'MiddleInit' and 'LastName' and
include a period after the middle initial. Using a plus sign before the
middle initial kept the period from showing up if the middle initial was
blank. Seems Access 2003 doesn't recognize this simple trick.

So the question is, how do create a full name in a query without having a
period show up between FirstName and LastName if there is no middle name?

Thank you


If [MiddleInit] <> Null Then
sFullName = [FirstName] & " " & [MiddleInit] & " " & [LastName]
Else
sFullName = [FirstName] & " " & [LastName]
End If

--
James
Nov 13 '05 #2
"Rebecca Smith" <rp*****@pcez.com> wrote in message
news:11************@corp.supernews.com...
In past versions of Access it was a simple matter to create a persons full
name from the three strings 'FirstName' 'MiddleInit' and 'LastName' and
include a period after the middle initial. Using a plus sign before the
middle initial kept the period from showing up if the middle initial was
blank. Seems Access 2003 doesn't recognize this simple trick.

So the question is, how do create a full name in a query without having a
period show up between FirstName and LastName if there is no middle name?

Use an IsNull test in an in-line "If" statement.

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #3
Rebecca Smith wrote:
In past versions of Access it was a simple matter to create a persons
full name from the three strings 'FirstName' 'MiddleInit' and
'LastName' and include a period after the middle initial. Using a
plus sign before the middle initial kept the period from showing up
if the middle initial was blank. Seems Access 2003 doesn't recognize
this simple trick.

So the question is, how do create a full name in a query without
having a period show up between FirstName and LastName if there is no
middle name?


Something else is going on because there is no change to Access 2003
affecting how the + and & operators work with respect to Null propogation.
I just performed the following test in the immediate window of Access
2003...

?"test" & ("." & Null) & "TEST"
test.TEST

?"test" & ("." + Null) & "TEST"
testTEST

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #4
James Arnold wrote:
Rebecca Smith wrote:
In past versions of Access it was a simple matter to create a persons
full name from the three strings 'FirstName' 'MiddleInit' and
'LastName' and include a period after the middle initial. Using a plus
sign before the middle initial kept the period from showing up if the
middle initial was blank. Seems Access 2003 doesn't recognize this
simple trick.

So the question is, how do create a full name in a query without
having a period show up between FirstName and LastName if there is no
middle name?

Thank you


If [MiddleInit] <> Null Then
sFullName = [FirstName] & " " & [MiddleInit] & " " & [LastName]
Else
sFullName = [FirstName] & " " & [LastName]
End If


Of course, you know why you will never get the middle initial displayed
there. ;-)
Nov 13 '05 #5
Rick Brandt wrote:
Something else is going on because there is no change to Access 2003
affecting how the + and & operators work with respect to Null propogation.
I just performed the following test in the immediate window of Access
2003...

?"test" & ("." & Null) & "TEST"
test.TEST

?"test" & ("." + Null) & "TEST"
testTEST


Perhaps there are zero length strings in the middle initial?

Opposite of Nz is...
Function Zn(pvar As Variant, Optional pvarZLS As Variant = "")
If pvarZLS = pvar Then
Zn = Null
Else
Zn = pvar
End If
End Function
Nov 13 '05 #6
Trevor Best <no****@nospam.invalid> wrote in
news:42***********************@news.zen.co.uk:
Rick Brandt wrote:
Something else is going on because there is no change to Access
2003 affecting how the + and & operators work with respect to
Null propogation. I just performed the following test in the
immediate window of Access 2003...

?"test" & ("." & Null) & "TEST"
test.TEST

?"test" & ("." + Null) & "TEST"
testTEST


Perhaps there are zero length strings in the middle initial?

Opposite of Nz is...
Function Zn(pvar As Variant, Optional pvarZLS As Variant = "")
If pvarZLS = pvar Then
Zn = Null
Else
Zn = pvar
End If
End Function


Zero-length strings are an abomination.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #7
David W. Fenton wrote:
Zero-length strings are an abomination.


Actually they're not, in true relational style, if the middle initial is
null, it means the data is missing, could be that the middle name is
unknown. If it's a zero length string it means the person doesn't have a
middle name.

The only problem is that nulls are indistinguishable from zero length
strings to the human eye.

If it were a SSN say, and the person is not a US national then they
probbly don't have one, it's acceptible to have "N/A" entered into the
SSN field but you don't want to see "Joe N/A Blow" on a report.

(yes I just noticed my spelling mistake above but it looks so funny I
don't want to correct it)
Nov 13 '05 #8
Trevor Best <no****@nospam.invalid> wrote in
news:42**********************@news.zen.co.uk:
David W. Fenton wrote:
Zero-length strings are an abomination.
Actually they're not, in true relational style, if the middle
initial is null, it means the data is missing, could be that the
middle name is unknown. If it's a zero length string it means the
person doesn't have a middle name.


I've never had an application where that distinction was of any use
whatsoever.
The only problem is that nulls are indistinguishable from zero
length strings to the human eye.
Well, I encounter the problem most often with people who are too
inexperienced to write code that enters data into tables without
needing to write ZLS's into them, so they allow ZLS's in their field
definitions. This leads to massive problems.

These are mostly web developers, who, in my experience, have a
particular variety of stupidity when it comes to database design.
If it were a SSN say, and the person is not a US national then
they probbly don't have one, it's acceptible to have "N/A" entered
into the SSN field but you don't want to see "Joe N/A Blow" on a
report.
I can't think of a type of data where a ZLS used to distinguish
UNKNOWN from NONE would be at all useful. Like you say, you'd
probably want some default value other than ZLS. It certainly would
make coding a lot simpler to do that.
(yes I just noticed my spelling mistake above but it looks so
funny I don't want to correct it)


My eyes are acting up today and I can't see your misspelling.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9
David W. Fenton wrote:

My eyes are acting up today and I can't see your misspelling.


probbly :-)
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
20
by: hagai26 | last post by:
I am looking for the best and efficient way to replace the first word in a str, like this: "aa to become" -> "/aa/ to become" I know I can use spilt and than join them but I can also use regular...
3
by: John Ford | last post by:
For simple string concatenation, is there a difference between... Dim s As String s += "add this to string" ....and... Dim s As String s = String.Concat(s, "add this to string")
9
by: Justin M. Keyes | last post by:
Hi, Please read carefully before assuming that this is the same old question about string concatenation in C#! It is well-known that the following concatenation produces multiple immutable...
16
by: Mark A. Sam | last post by:
Hello, I am having a problem with imputting into a string variable: Dim strSQL As String = "INSERT INTO tblContactForm1 (txtName, txtCompany, txtPhone, txtEmail, txtComment, chkGrower,...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
12
by: Richard Lewis Haggard | last post by:
I thought that the whole point of StringBuilder was that it was supposed to be a faster way of building strings than string. However, I just put together a simple little application to do a...
34
by: Larry Hastings | last post by:
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. ...
10
by: =?Utf-8?B?RWxlbmE=?= | last post by:
I am surprised to discover that c# automatically converts an integer to a string when concatenating with the "+" operator. I thought c# was supposed to be very strict about types. Doesn't it seem...
34
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.