Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transpose poorly designed table in Access 2000 query

Status
Not open for further replies.

Flopper

Technical User
Jan 19, 2001
140
AT
Greetings,

I'm attempting to transpose a poorly designed table into a query but without much luck.

The table contains an ID field and 20 additional fields containing dates (Dt1 to Dt20).
ID[tab][tab][tab]Dt1[tab][tab][tab]Dt2[tab][tab][tab]Dt3[tab][tab][tab]Dt4[tab]

I need to tranpose the table to show a row for each Dt field. i.e.
Id[tab]Dt1
Id[tab]Dt2
Id[tab]Dt3
Id[tab]Dt4

How can this be achieved? I know it can be done by multiple single line queries and union statements but this seems inefficient.

Any help truly appreciated.

Thanks
 
it can be done by multiple single line queries and union statements

inefficient or not, i think that's the only way

r937.com | rudy.ca
 
Try a union query like:
Code:
SELECT ID, Dt1 as TheDate, 1 as DateNum
FROM tblPoorlyDesigned
UNION ALL
SELECT ID, Dt2, 2
FROM tblPoorlyDesigned
UNION ALL
SELECT ID, Dt3, 3
FROM tblPoorlyDesigned
UNION ALL
SELECT ID, Dt4, 4
FROM tblPoorlyDesigned
UNION ALL
---etc---
SELECT ID, Dt20, 20
FROM tblPoorlyDesigned;



Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top