View Full Version : Help with a semi-pivot,crosstab type thing


JTPlay
08-24-2006, 05:51 PM
Hey all, I've been banging my head all day trying to find a method and have nothing. Perhaps someone could guide me towards the right path... Here's a generic simplification of what I have:

ID# - Friend
1 - Fred
1 - George
2 - Fred
3 - Bill
3 - Ray
3 - Scott

Here's what I'm hoping to end up with:

ID# - Friends
1 - Fred, George
2 - Fred
3 - Bill, Ray, Scott

or even this would get me there:

ID# - Friend1 - Friend2 - Friend3
1 - Fred - George
2 - Fred
3 - Bill - Ray - Scott

I'm dealing with thousands of id#'s and thousands of possible friend's names.

Any help out there? If I need to explain myself better, just ask and i'll write some more...

thanx for any help you can offer...

Jim

P.S. I'm only a lite-weight in programming. I've been trying with a thousand different query methods so far using temporary tables and anything else I could possibly imagine...

Teau
08-25-2006, 04:50 AM
The first thing you need to do is to create an extra field, which is the number of the occurrence within an ID#:
ID# - num - Friend
1 - 1 - Fred
1 - 2 -George
2 - 1 - Fred
3 - 1 - Bill
3 - 2 - Ray
3 - 3 - Scott

This number you can use as column-id (heading) in a crosstable

The query to create this number is in my own thread (updatequery from selectquery) from this afternoon. It's only a selectquery, not yet an update-query, but it's a start

Teau
08-25-2006, 05:03 AM
I'm sorry, my thread is called "Using count in update query"

The_Doc_Man
08-25-2006, 09:35 AM
You MIGHT be talking about a cross-tab query, though perhaps it is instead really a GROUP BY operation. Part of the problem is the simple set of rules:

Access cannot tell you what it does not know itself.

Access cannot do for you what you yourself could not do on paper.

Therefore, if you don't have the right data in the records or don't know what it is you wanted to do with the records in order to show the relationships you want, you can't get there from here.

Normally, turning a vertical list of records into a horizontal one is not the way you do this. Access likes vertical arrays. But a report with a break on that grouping number would at least sort everything for you.