man, I just don't know where to start ... so how about the beginning ...
I have 100+ records in table "surveys", which has 100+ fields ... I just need "Project_Name" ... but I need every record in column "Project_Name" to be in my second table, which will be created dynamically, so lets just call it "ranking" for now.
"ranking" will have a primary key ID and 2 columns "Project_Name" and "Rank"
I don't really need "ranking" to be associated with "surveys" if I update "ranking" from the "surveys" table, so that makes it easier .. I think ..
So, after I create the table
sql = "CREATE TABLE " & TableName & " (ID INT Identity(1,1), PRIMARY KEY (ID))"
I add the fields as needed, making sure to catch any errors if the field already exists ...
sql = "ALTER TABLE ranking ADD Rank NUMBER"
Then I want to copy the entire "Project_Name" column to the new table ...
sql = "INSERT INTO ranking (Project_Name) SELECT DISTINCT Project_Name FROM surveys"
I don't wan't duplicate entries, so I have to use the DISTINCT .. at least I think I have to ...
Now, if there were any deleted records in "surveys", I want those same records to disappear in "ranking" .. should I simply delete the "Project_Name" column from "ranking" and recreate it using the code to copy the column into the new table ... and if I do that, I suppose I still have to delete any records where the values don't match ...
I suppose the real kicker here is that if I delete the column first, then I don't have the ability to ensure the ranks are assigned to the correct project.