Normalizing a flat table w/VBA 
Author Message
 Normalizing a flat table w/VBA

Greetings, all -

I have a table created using an Access add-in utility (FMS' Total Access
Statistics). The TAS scenario, when run, calculates correlation
coefficients (r values) and generates an output table of values in a
nonnormalized "matrix" form. Here're some sample data to illustrate
(mind the linewrap):

Datafield     Apples     Oranges     Pears     Tangerines
Apples        1.0000     0.1234      0.9876    0.2345
Oranges       0.1234     1.0000      0.5678    0.9988
Pears         0.9876     0.5678      1.0000    0.3456
Tangerines    0.2345     0.9988      0.3456    1.0000

I need to stack these data in a tall-skinny form in order to look at
each comparison and run additional analyses on the results. I am
presently using a "normalizing Union query," which looks something like
this in SQL:

SELECT DataField as Fruit1, "Apples" AS Fruit2, [Apples] AS RValue FROM
MyTable WHERE[DataField]<>"Apples"
UNION
SELECT DataField as Fruit1, "Oranges" AS Fruit2, [Oranges] AS RValue
FROM MyTable WHERE [DataField]<>"Oranges"
UNION
SELECT...yada yada yada...

This returns a recordset which resembles the following:

Fruit1     Fruit2     RValue
Apples     Oranges    0.1234
Apples     Pears      0.9876
Apples     Tangerines 0.2345
Oranges    Apples     0.1234
Oranges    Pears      0.5678

...and so on.

But this "normalizing Union query" requires me to hard-code the name of
each fruit. Is there any way to programmatically rearrange this
recordset in the slightly-more-normalized form shown above? Any help
would be very much appreciated.

TIA,

LeAnne

PS. Using Access 97, so any sample code needs to be DAO. Thanks!



Sat, 26 Mar 2005 00:49:46 GMT  
 Normalizing a flat table w/VBA
LeAnne,

I think I have code that does what you need; e-mailed it to your address. If


Quote:
> Greetings, all -

> I have a table created using an Access add-in utility (FMS' Total Access
> Statistics). The TAS scenario, when run, calculates correlation
> coefficients (r values) and generates an output table of values in a
> nonnormalized "matrix" form. Here're some sample data to illustrate
> (mind the linewrap):

> Datafield     Apples     Oranges     Pears     Tangerines
> Apples        1.0000     0.1234      0.9876    0.2345
> Oranges       0.1234     1.0000      0.5678    0.9988
> Pears         0.9876     0.5678      1.0000    0.3456
> Tangerines    0.2345     0.9988      0.3456    1.0000

> I need to stack these data in a tall-skinny form in order to look at
> each comparison and run additional analyses on the results. I am
> presently using a "normalizing Union query," which looks something like
> this in SQL:

> SELECT DataField as Fruit1, "Apples" AS Fruit2, [Apples] AS RValue FROM
> MyTable WHERE[DataField]<>"Apples"
> UNION
> SELECT DataField as Fruit1, "Oranges" AS Fruit2, [Oranges] AS RValue
> FROM MyTable WHERE [DataField]<>"Oranges"
> UNION
> SELECT...yada yada yada...

> This returns a recordset which resembles the following:

> Fruit1     Fruit2     RValue
> Apples     Oranges    0.1234
> Apples     Pears      0.9876
> Apples     Tangerines 0.2345
> Oranges    Apples     0.1234
> Oranges    Pears      0.5678

> ...and so on.

> But this "normalizing Union query" requires me to hard-code the name of
> each fruit. Is there any way to programmatically rearrange this
> recordset in the slightly-more-normalized form shown above? Any help
> would be very much appreciated.

> TIA,

> LeAnne

> PS. Using Access 97, so any sample code needs to be DAO. Thanks!



Sat, 26 Mar 2005 23:18:36 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Normalizing a table with VBA

2. Working wit Normalized Table

3. Working with Normalized Table

4. Normalizing non-normal tables already containing data;OR changing columns into rows

5. TreeView - Hierarchical Data from Flat Table

6. DAO and MSAccess - creating flat file from table

7. flat combobox with flat dropdown

8. Copy fields from record in table A to record in table B using VBA

9. Copy Record from Table 1 to Table 2 - Acc97 - VBA

10. Code to normalize a database

11. normalizing

12. Normalize String Spacing

 

 
Powered by phpBB® Forum Software