TDGM
04-09-2009, 07:43 AM
Hi,
I keep reading the posts on this forum and they have helped me a lot. This is the first time I am posting a question.My apologies if this has been asked before but i Searched extensively and cud not find an answer.
I am trying to update a field with multiple values based on a criteria(date). Basically the table holds monthend benchmark data for last 10 years for various indices and everytime a new benchmark is added,I have to add a new column to the table which I h ave done succesfully using the ALTER TABLE query . The next step is to populate the column with last 10 yrs month end data which is in EXcel. I am trying to use UPDATE query but I cant figure out how update all 10 yrs at once based on onthend dates.
tablename- benchmarkdata
Hers is the query I se to ALTER the table to add a column( I am picking up new column name from a cell in Excel)- it works
dbcon.Execute "ALTER TABLE benchmarkdata ADD COLUMN [" & Range("Iv" & i & "").value & "] Double"
The next query is to Update the values in the new column
This query qorks but it only updates one value ata a time by matching one date field( all from excel)
dbcon.Execute "UPDATE benchmarkdata SET benchmarkdata.[" & Range("Iv" & i & "").value & "] = " & Range("a" & i + 1 & "").value & " WHERE (([Monthyear]=#" & Range("c" & i + 1 & "").value & "#))"
HOW DO I EXTEND IT to be able toupdfadte multiple values
???
this is a query I wrote( newupload is the name of the sheet, E:E has the update values and D:D has the dates whcih cxorrosp[ond tot he dates in the benchmark table)- THIS IS GIVING AN ERROR
dbcon.Execute "UPDATE benchmarkdata,[newupload$] SET benchmarkdata.[r index] = [newupload$E:E] WHERE (([benchmarkdata].[Monthyear]=[newupload$D:D])) IN '" & sXlsPath1 & "' 'EXCEL 8.0;'"
pls help!!!!
I keep reading the posts on this forum and they have helped me a lot. This is the first time I am posting a question.My apologies if this has been asked before but i Searched extensively and cud not find an answer.
I am trying to update a field with multiple values based on a criteria(date). Basically the table holds monthend benchmark data for last 10 years for various indices and everytime a new benchmark is added,I have to add a new column to the table which I h ave done succesfully using the ALTER TABLE query . The next step is to populate the column with last 10 yrs month end data which is in EXcel. I am trying to use UPDATE query but I cant figure out how update all 10 yrs at once based on onthend dates.
tablename- benchmarkdata
Hers is the query I se to ALTER the table to add a column( I am picking up new column name from a cell in Excel)- it works
dbcon.Execute "ALTER TABLE benchmarkdata ADD COLUMN [" & Range("Iv" & i & "").value & "] Double"
The next query is to Update the values in the new column
This query qorks but it only updates one value ata a time by matching one date field( all from excel)
dbcon.Execute "UPDATE benchmarkdata SET benchmarkdata.[" & Range("Iv" & i & "").value & "] = " & Range("a" & i + 1 & "").value & " WHERE (([Monthyear]=#" & Range("c" & i + 1 & "").value & "#))"
HOW DO I EXTEND IT to be able toupdfadte multiple values
???
this is a query I wrote( newupload is the name of the sheet, E:E has the update values and D:D has the dates whcih cxorrosp[ond tot he dates in the benchmark table)- THIS IS GIVING AN ERROR
dbcon.Execute "UPDATE benchmarkdata,[newupload$] SET benchmarkdata.[r index] = [newupload$E:E] WHERE (([benchmarkdata].[Monthyear]=[newupload$D:D])) IN '" & sXlsPath1 & "' 'EXCEL 8.0;'"
pls help!!!!