PDA

View Full Version : Access Query to convert colums and rows


enchanting01
Jan 13, 2009, 12:57 PM
Okay, this is what I have been beating my head trying to do...

I have two tables similar to the following

Table1:
Product_ID | Size
b1234 | L
b1234 | XL
c3567 | S
c3567 | M
c3567 | L

Table2:
Product_ID | Description
b1234 | Cool T-Shirt
c3567 | Awesome T-shirt

I need to combine the two tables so that it looks like this:
Product_ID | Description | Size
b1234 | Cool T-Shirt | L, XL
c3567 | Awesome T-Shirt | S, M, L

Any help would be greatly appreciated!

ScottGem
Jan 13, 2009, 01:01 PM
I've posted a link to an article that will do what you need:

Utter Access Discussion Forums - Code To Concatenate Multiple Records Into A Single Field (http://www.utteraccess.com/forums/showflat.php?Cat=&Board=48&Number=228834&Zf=f48&Zw=concatenate&Zg=0&Zl=a&Main=228834&Search=true&where=&Zu=66&Zd=l&Zn=&Zt=1&Zs=b&Zy=#Post228834&Zp)=

Basically what you need to do is loop through the records in Table 1 and concatenate the size values.