If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Concatenating Access Fields with Excel Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-10-06, 12:15
bugsycat bugsycat is offline
Registered User
 
Join Date: Aug 2006
Posts: 4
Question Concatenating Access Fields with Excel Query

Hi
I need to concatentate 2 text fields and show the result in a 3rd created field.

I can do this fine within Access using -

3rdFieldName: [Field1Name] & [Field2Name]
but I get a syntax error when I try using an Excel ODBC Query

The best I was able to manage using an Excel ODBC Query was to type the following into the SQL editor -

SELECT [tableName.Field1] & [tableName.Field2] AS [3rdFieldName] FROM Datasource

This returns just the concatenated fields (OK) but I can't add any of the other (normal) fields.

Katherine
Reply With Quote
  #2 (permalink)  
Old 08-10-06, 22:56
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 533
Tried it with SQL query Editor and with ADO using Excel VB and didn't have any trouble. However you have to be careful to use the correct syntax. It looks like you have the wrong syntax in your SQL String where you enclosed the Tablename and the Fieldname in the brackets. You should separate the Table name and field names. Use the Query builder in Access or the wizard in Query Editor to get an initial string with the correct syntax.

Adapted from Access Editor
strSQL = "SELECT [Field One], [Field Two] & [Field Three] AS ConcatFld" & _
" FROM TableName"


SQL Query Editor
SELECT Table.`Fld One`, Table.FieldTwo & Table.FldThree AS ConcatFld
FROM Table Table
ORDER BY Table.`Fld One`
__________________
~

Bill
Reply With Quote
  #3 (permalink)  
Old 08-11-06, 05:19
bugsycat bugsycat is offline
Registered User
 
Join Date: Aug 2006
Posts: 4
Still Stuck

Thanks Bill but I'm still stuck

I've attached a screen shot of what I'm trying to do.
I need to display the 2 addresses in the example AND a third new column which will be the result of concatenating them in the same query.
Kind regards, Katherine
Reply With Quote
  #4 (permalink)  
Old 08-11-06, 05:25
bugsycat bugsycat is offline
Registered User
 
Join Date: Aug 2006
Posts: 4
Sorry no Screen shot

Sorry couldn't figure out how to attach a document, so here's the SQL from the query which returns the 2 columns I need to concatenate. I would call the calulated colum Address6.


SELECT tblTenant.CorrespondenceAddress4, tblTenant.CorrespondenceAddress5
FROM `P:\PropertyDatabase\ProcessProperty_KM`.tblTenant tblTenant
Reply With Quote
  #5 (permalink)  
Old 08-11-06, 12:59
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 533
SELECT tblTenant.CorrespondenceAddress4 & ' ' & tblTenant.CorrespondenceAddress5 AS 'Address6'
FROM `P:\PropertyDatabase\ProcessProperty_KM`.tblTenant


This format worked. Did get an alert that the query can not be displayed graphically, but the query works fine.
__________________
~

Bill
Reply With Quote
  #6 (permalink)  
Old 08-15-06, 07:19
bugsycat bugsycat is offline
Registered User
 
Join Date: Aug 2006
Posts: 4
Thank you

Thank very much Bill. That worked perfectly.
Katherine
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On