PC Review


Reply
Thread Tools Rate Thread

combine info into

 
 
Flecal
Guest
Posts: n/a
 
      12th Nov 2008
I have many rows of names. The data is sorted out into the following
columns: First, Last, Address, City, State, Zip.

John Doe 1234 E Street Los Angeles CA 12345
Jane Doe 1234 E Street Los Angeles CA 12345
Bob Smith 4321 Tree Ave Denver CO 54321
Joe Johnson 987 North Lane Philadelphia PA 65432
Sue Johnson 987 North Lane Philadelphia PA 65432
Lisa Johnson 987 North Lane Philadelphia PA 65432

I want to combine John & Jane Doe into one row, Joe, Sue & Lisa Johnson into
one row, etc.

what can I do to look at the addresses, see if they're the same, look at
last names, see if they're the same, then combine first names into one row
with the appropriate last name and address info?
 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      12th Nov 2008
Query one: Identify the unique values

SELECT Last, Address, City, State, ZIP
FROM [YourTable]
GROUP BY Last, Address, City, State, ZIP

Query Two - uses a VBA concatenate function - see
http://www.rogersaccesslibrary.com/f...sts.asp?TID=16
You will need to copy the function and save it to a VBA module in your database.

SELECT Last, Address, City, State, ZIP
, Concatenate("SELECT First FROM [YourTable] WHERE Last=""" & Last & """ AND
Address = """ & Address & """ AND City = """ & City & """ AND ZIP = """ & ZIP
& """", ",")
FROM [QueryOne]

Also, you will need to handle changing the last comma to an ampersand. Or you
could delimit all the names with an ampersand instead of a comma. So you end
up with
Joe & Sue & Lisa instead of Joe, Sue & Lisa.

Additionally, you might want to add an order by clause to the query being used
by the concatenate function. But with the data given the only thing you could
do would be to return the names in alphabetic order.

If you are creating a report, you might want to base the report on queryOne
and assign the first names to an unbound control using VBA and the concatenate
function to create the first names value.


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

Flecal wrote:
> I have many rows of names. The data is sorted out into the following
> columns: First, Last, Address, City, State, Zip.
>
> John Doe 1234 E Street Los Angeles CA 12345
> Jane Doe 1234 E Street Los Angeles CA 12345
> Bob Smith 4321 Tree Ave Denver CO 54321
> Joe Johnson 987 North Lane Philadelphia PA 65432
> Sue Johnson 987 North Lane Philadelphia PA 65432
> Lisa Johnson 987 North Lane Philadelphia PA 65432
>
> I want to combine John & Jane Doe into one row, Joe, Sue & Lisa Johnson into
> one row, etc.
>
> what can I do to look at the addresses, see if they're the same, look at
> last names, see if they're the same, then combine first names into one row
> with the appropriate last name and address info?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine all info Confused87 Microsoft Access Queries 1 31st May 2009 03:23 PM
Combine info from queries gcutter Microsoft Access Queries 0 14th May 2009 08:02 PM
Combine 2 tables info in 1 Query David W Microsoft Access Form Coding 1 20th Apr 2005 02:20 AM
combine info in spreadsheet Jyl Microsoft Excel Misc 1 16th Nov 2004 06:07 PM
Combine Info from Two Tables =?Utf-8?B?SmVyZW15?= Microsoft Access Queries 4 26th Feb 2004 10:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:27 PM.