Display Data where # of columns can vary

It_thug

Registered User.
Local time
Today, 15:36
Joined
Oct 22, 2009
Messages
59
Okay, been struggling with this for a while. To preface, I am not a VBA developer, and I don't want anyone writing the code for me. But need some help. Any given is very appreciated.

I have a situation where I have a range of data that I need to be displayed, but the number of columns can change.

For instance, the Query(table) will look like this.

Company# Report_year Value
1 2000 2500
1 2001 1976
1 2002 2010
2 2000 800
2 2001 856
2 2002 857


And so on. But, the number of years in Report year can vary. So I can't do a static Join but need to figure out a way to display the data so that it looks like this:

Company# Year 2000 Year 2001 Year 2002
1 2500 1976 2010
2 800 856 857

Now, I can get it to display this way with a Cross Tab Query. But, that isn't usable for the End Users in this case.

Now I was pointed to

http://www.access-programmers.co.uk/forums/showthread.php?t=106426&highlight=wayne+recordset

And that seems to be very similiar to what I need. And I was able to get it to work, a little bit. But it was giving too much data, and not displaying under the headers. (so for 10 years, I was getting 15 pieces of data. Not sure why).

I am lost as to where to go next. And again, I do not want anyone just writing something up.

I scrapped what I was using, or I would post that.

Any nudge in the right direction (like what I should be trying to use, etc) would be very much appreciated.

(the problem with the pivot table, is they want to be able to export this to Excel as well, and when i do that, needs to do aggregate function which messes with the data.)
 
Last edited:
okay.. i was just thinking, that If I could do a cross tab query .. that could probably do it. But I haven't been able to get that to work because I'm not really trying to sum anything up..... so maybe not.
 
Just thought also, that if I could just get it to create a table, with the Report years each with their own column, I could work with that.
 
It would work yes
Jus make sure you drop the table when you close the report
 
It would work yes
Jus make sure you drop the table when you close the report

I'm not really sure how to do that either. I was just saying that if I could figure that part out, I could work with it that way.
 
Was able to get this to work as I needed it to, using the Pivot table. The problem was that one of the fields was a "Memo" field, which made the Export to Excel not work.

So... thanks for everyone that looked at this.
 

Users who are viewing this thread

Back
Top Bottom