I start with data that looks like this (I do some cleanup in Excel to get it like this):
ID,RecordID,Field1,Field2,Field3,Field4,Field5
1,ABC_001,this,that,,,
2,GER_056,that,other thing,,,
3,HTR_895,stuff,nothing,more stuff,blah,
4,RTZ_456,that,more stuff,cars,trucks,vans
I turn it into this:
RecordID,Values
ABC_001,that
ABC_001,this
GER_056,other thing
GER_056,that
HTR_895,blah
HTR_895,more stuff
HTR_895,nothing
HTR_895,stuff
RTZ_456,vans
RTZ_456,trucks
RTZ_456,cars
RTZ_456,more stuff
RTZ_456,that
Here is how I get there:
1. Import data into Access, delimit on comma.
2. Run a Union query called qry1Data:
2. Run a SELECT to get rid of nulls:
Here is the problem:
I do not know how many "value" fields the original data might have. In this sample we have five, I might have up to 100 or down to one. So I made my UNION query handle five fields. The problem is that if I have less that five my UNION query prompts me for the values of whatever fields I do not have. Is there a way to avoid this prompt? If so I can just make the UNION query handle like 100 fields.
I joined this forum in 2005. I am still a hack.
ID,RecordID,Field1,Field2,Field3,Field4,Field5
1,ABC_001,this,that,,,
2,GER_056,that,other thing,,,
3,HTR_895,stuff,nothing,more stuff,blah,
4,RTZ_456,that,more stuff,cars,trucks,vans
I turn it into this:
RecordID,Values
ABC_001,that
ABC_001,this
GER_056,other thing
GER_056,that
HTR_895,blah
HTR_895,more stuff
HTR_895,nothing
HTR_895,stuff
RTZ_456,vans
RTZ_456,trucks
RTZ_456,cars
RTZ_456,more stuff
RTZ_456,that
Here is how I get there:
1. Import data into Access, delimit on comma.
2. Run a Union query called qry1Data:
Code:
SELECT [RecordID] , [Field1] AS [Values] FROM [tblData] UNION ALL
SELECT [RecordID] , [Field2] AS [Values] FROM [tblData] UNION ALL
SELECT [RecordID] , [Field3] AS [Values] FROM [tblData] UNION ALL
SELECT [RecordID] , [Field4] AS [Values] FROM [tblData] UNION ALL
SELECT [RecordID] , [Field5] AS [Values] FROM [tblData]
ORDER BY [RecordID];
2. Run a SELECT to get rid of nulls:
Code:
SELECT qry1Data.RecordID, qry1Data.Values
FROM qry1Data
WHERE (((qry1Data.Values) Is Not Null));
Here is the problem:
I do not know how many "value" fields the original data might have. In this sample we have five, I might have up to 100 or down to one. So I made my UNION query handle five fields. The problem is that if I have less that five my UNION query prompts me for the values of whatever fields I do not have. Is there a way to avoid this prompt? If so I can just make the UNION query handle like 100 fields.
I joined this forum in 2005. I am still a hack.