Results 1 to 7 of 7
  1. #1
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37

    Constract of Multiple Fields

    How can I combine the following table fields to look like such in a query?
    I have tried this in excel as well as a query in access and no success for four days now..

    tbl_City_State_Zip

    City State Zip
    Raleigh NC 29706
    Raleigh NC 29707


    Raleigh NC 29708
    Raleigh NC 29709

    Query output would be:

    Raleigh NC 29706 29707 29708 29709,
    Last edited by KLynch0803; 01-31-2010 at 08:52 PM. Reason: Typo in city name

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    That's not normally what a query does.

    Run a query grouping on city state; Then cycle through that query's recordset in DAO or ADO VBA concantenating the various zipcodes.

  3. #3
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37
    Quote Originally Posted by llkhoutx View Post
    That's not normally what a query does.

    Run a query grouping on city state; Then cycle through that query's recordset in DAO or ADO VBA concantenating the various zipcodes.
    Im not sure how to do that exactly (obviously to my own self being lost)

    I do have a query that exists that just gives me the City and States list which is qry_City_State.

    How would I write the DAO to cancantenate the rest so its all in one field?

  4. #4
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Giving you the code would be beyond your obvious comprehension and do you a great disservice.

    Get you a good Hornbook on the subject. I recommend the O'Reilly publication, Access Databases, 3rd Edition. Any of the earlier editions would be too ok.

  5. #5
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37
    Quote Originally Posted by llkhoutx View Post
    Giving you the code would be beyond your obvious comprehension and do you a great disservice.

    Get you a good Hornbook on the subject. I recommend the O'Reilly publication, Access Databases, 3rd Edition. Any of the earlier editions would be too ok.

    Ok why couldnt I use something like this in a sql query?

    Code:
     
    SELECT tbl_City_zip.[City]+' '+Concat([city],[state], [zip]"city='" & city & "'") AS result
    FROM tbl_city_zip
    GROUP BY tbl_city_zip.[city];

  6. #6
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    By definition queries aren't generally used to combine data on different rows.

    Trying building a crosstab query with zipcodes as columns and city state as row, then query that query combining all the zipcode columns in one column with city state. Depending on the number of zipcodes, this may not be practical.

  7. #7
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    Access does not recognise the Concat Function as far as I a am aware

    here is a link http://www.mvps.org/access/modules/mdl0004.htm to an example of what you are looking for.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. multiple fields in separate records
    By Fredo0709 in forum Database Design
    Replies: 9
    Last Post: 04-09-2010, 12:23 PM
  2. Replies: 1
    Last Post: 12-10-2009, 08:41 PM
  3. Populating multiple fields
    By jjcaprio in forum Programming
    Replies: 11
    Last Post: 08-16-2009, 01:51 PM
  4. Multiple Fields In One Combo Box.
    By caljohn527 in forum Forms
    Replies: 1
    Last Post: 02-20-2009, 03:07 PM
  5. One table multiple fields identical properties.
    By swampdonkey in forum Queries
    Replies: 2
    Last Post: 09-29-2006, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums