dbTalk Databases Forums  

Concatenating Fields in Query

comp.databases.ms-access comp.databases.ms-access


Discuss Concatenating Fields in Query in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Darlington
 
Posts: n/a

Default Concatenating Fields in Query - 09-14-2011 , 05:23 AM






I have a query in Access 2002 which combines two fields (FirstName &
LastName) into a new field 'FullName' using:
FullName: FirstName & " " & LastName.

In the first instance I have:
FirstName = Graeme
LastName = Wright
This results in a FullName of "Graeme Wright" which is fine.

In a second case, I have
FirstName = Brian
LastName = Wright
This results in a FullName of "Brian" instead of "Brian Wright".

I feel I'm missing something obvious, but can someone let me know what it
is?


--
Bob Darlington
Brisbane

Reply With Quote
  #2  
Old   
Phil
 
Posts: n/a

Default Re: Concatenating Fields in Query - 09-14-2011 , 05:41 AM






On 14/09/2011 11:23:16, "Bob Darlington" wrote:
Quote:
I have a query in Access 2002 which combines two fields (FirstName &
LastName) into a new field 'FullName' using:
FullName: FirstName & " " & LastName.

In the first instance I have:
FirstName = Graeme
LastName = Wright
This results in a FullName of "Graeme Wright" which is fine.

In a second case, I have
FirstName = Brian
LastName = Wright
This results in a FullName of "Brian" instead of "Brian Wright".

I feel I'm missing something obvious, but can someone let me know what it
is?


Have you got a line feed or carriage return after Brian ( but not after
Greame), in other words is Brian Wright printing on 2 lines, and you are only
seeing the first line?

Phil

Reply With Quote
  #3  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Concatenating Fields in Query - 09-14-2011 , 04:26 PM



Good thought Phil. But no CR.

--
Bob Darlington
Brisbane
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 14/09/2011 11:23:16, "Bob Darlington" wrote:
I have a query in Access 2002 which combines two fields (FirstName &
LastName) into a new field 'FullName' using:
FullName: FirstName & " " & LastName.

In the first instance I have:
FirstName = Graeme
LastName = Wright
This results in a FullName of "Graeme Wright" which is fine.

In a second case, I have
FirstName = Brian
LastName = Wright
This results in a FullName of "Brian" instead of "Brian Wright".

I feel I'm missing something obvious, but can someone let me know what it
is?



Have you got a line feed or carriage return after Brian ( but not after
Greame), in other words is Brian Wright printing on 2 lines, and you are
only
seeing the first line?

Phil

Reply With Quote
  #4  
Old   
Douglas J Steele
 
Posts: n/a

Default Re: Concatenating Fields in Query - 09-14-2011 , 06:13 PM



What about some other unprintable character, such as a Null (Chr(0))?

"Bob Darlington" wrote in message
news:4e711af7$0$2444$afc38c87 (AT) news (DOT) optusnet.com.au...

Good thought Phil. But no CR.

--
Bob Darlington
Brisbane
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 14/09/2011 11:23:16, "Bob Darlington" wrote:
I have a query in Access 2002 which combines two fields (FirstName &
LastName) into a new field 'FullName' using:
FullName: FirstName & " " & LastName.

In the first instance I have:
FirstName = Graeme
LastName = Wright
This results in a FullName of "Graeme Wright" which is fine.

In a second case, I have
FirstName = Brian
LastName = Wright
This results in a FullName of "Brian" instead of "Brian Wright".

I feel I'm missing something obvious, but can someone let me know what it
is?



Have you got a line feed or carriage return after Brian ( but not after
Greame), in other words is Brian Wright printing on 2 lines, and you are
only
seeing the first line?

Phil

Reply With Quote
  #5  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Concatenating Fields in Query - 09-14-2011 , 08:57 PM



Thanks Douglas,
That was it. There appears to be an extra character which looks like an
underscore after the first name. It is not a space character, and is only
visible when the whole field is selected (using F2).
My problem now is to find how it got there and to prevent it happening
again.
Any ideas?

--
Bob Darlington
Brisbane
"Douglas J Steele" <NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote

Quote:
What about some other unprintable character, such as a Null (Chr(0))?

"Bob Darlington" wrote in message
news:4e711af7$0$2444$afc38c87 (AT) news (DOT) optusnet.com.au...

Good thought Phil. But no CR.

--
Bob Darlington
Brisbane
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in message
news:j4q0d4$aj5$1 (AT) speranza (DOT) aioe.org...
On 14/09/2011 11:23:16, "Bob Darlington" wrote:
I have a query in Access 2002 which combines two fields (FirstName &
LastName) into a new field 'FullName' using:
FullName: FirstName & " " & LastName.

In the first instance I have:
FirstName = Graeme
LastName = Wright
This results in a FullName of "Graeme Wright" which is fine.

In a second case, I have
FirstName = Brian
LastName = Wright
This results in a FullName of "Brian" instead of "Brian Wright".

I feel I'm missing something obvious, but can someone let me know what
it
is?



Have you got a line feed or carriage return after Brian ( but not after
Greame), in other words is Brian Wright printing on 2 lines, and you are
only
seeing the first line?

Phil

Reply With Quote
  #6  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Concatenating Fields in Query - 09-14-2011 , 11:09 PM



I was wrong. There was a CR after the first name field.
Thankyou Phil and Douglas for your help.

--
Bob Darlington
Brisbane
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 14/09/2011 11:23:16, "Bob Darlington" wrote:
I have a query in Access 2002 which combines two fields (FirstName &
LastName) into a new field 'FullName' using:
FullName: FirstName & " " & LastName.

In the first instance I have:
FirstName = Graeme
LastName = Wright
This results in a FullName of "Graeme Wright" which is fine.

In a second case, I have
FirstName = Brian
LastName = Wright
This results in a FullName of "Brian" instead of "Brian Wright".

I feel I'm missing something obvious, but can someone let me know what it
is?



Have you got a line feed or carriage return after Brian ( but not after
Greame), in other words is Brian Wright printing on 2 lines, and you are
only
seeing the first line?

Phil

Reply With Quote
  #7  
Old   
Douglas J. Steele
 
Posts: n/a

Default Re: Concatenating Fields in Query - 09-15-2011 , 07:09 PM



One approach is to read the value into a variable, then loop through it
character by character, looking for the Ascii value. Once you know its
value, try using the Replace function to update the table to change that
character to a space (or zero length string, if that's more appropriate)

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele/AccessIndex.html
Co-author: "Access 2010 Solutions", published by Wiley
(no private e-mails, please)


"Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote

Quote:
Thanks Douglas,
That was it. There appears to be an extra character which looks like an
underscore after the first name. It is not a space character, and is only
visible when the whole field is selected (using F2).
My problem now is to find how it got there and to prevent it happening
again.
Any ideas?

--
Bob Darlington
Brisbane
"Douglas J Steele" <NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote in message
news:j4rcfc$rp2$1 (AT) dont-email (DOT) me...
What about some other unprintable character, such as a Null (Chr(0))?

"Bob Darlington" wrote in message
news:4e711af7$0$2444$afc38c87 (AT) news (DOT) optusnet.com.au...

Good thought Phil. But no CR.

--
Bob Darlington
Brisbane
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in message
news:j4q0d4$aj5$1 (AT) speranza (DOT) aioe.org...
On 14/09/2011 11:23:16, "Bob Darlington" wrote:
I have a query in Access 2002 which combines two fields (FirstName &
LastName) into a new field 'FullName' using:
FullName: FirstName & " " & LastName.

In the first instance I have:
FirstName = Graeme
LastName = Wright
This results in a FullName of "Graeme Wright" which is fine.

In a second case, I have
FirstName = Brian
LastName = Wright
This results in a FullName of "Brian" instead of "Brian Wright".

I feel I'm missing something obvious, but can someone let me know what
it
is?



Have you got a line feed or carriage return after Brian ( but not after
Greame), in other words is Brian Wright printing on 2 lines, and you are
only
seeing the first line?

Phil



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.