[算表] VBA 資料大量更新問題??

看板Office作者 (安安小成)時間16年前 (2010/06/08 23:07), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
軟體:Excel + Access 版本:2003 我利用 Excel VBA 來更新 資料庫 中的資料 因為我需要一次大量更新多筆資料 我利用 ListView 來做列表更新 所以我就寫了以下的更新語法 (資料庫連接語法省略) 只節錄部分語法~~ For i = ListView1.ListItems.Count To 1 Step -1 strsql = "select * from test where id = " & _ ListView1.ListItems(i).Text & "" Set myrst = myCon.Execute(strsql) myrst.MoveFirst Set myconn = New ADODB.Connection With myconn .Open myCon With New ADODB.Recordset .Open strsql, myconn, , adLockOptimistic .Fields("name").Value = ListView1.ListItems(i).SubItems(2) .Fields("data").Value = ListView1.ListItems(i).SubItems(3) ListView1.ListItems.Remove i .Update .Clos End With Set myconn = Nothing End With Next 以上這樣確實能達到我想要 一次大量更新欄位資料的目的 但是這樣跑個幾次後 發現 access 資料庫的檔案卻異常變大 從 1.5MB 飆到 30幾MB 想這是我的程式語法造成的 還是本身 access 資料庫就會這樣 想請高手們幫我解惑?? 如果是程式上可以再做修改優化 能不能幫我做修改 另外~~想請教一下 如果我有一個編號 LT0001 希望用 VBA +1 遞增下去 LT0001 加1 --> LT0002 ... 下去 如果要用 VBA 語法寫要如何辦到??? 謝謝~~ -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.81.234.21 ※ 編輯: evantw 來自: 219.81.234.21 (06/09 00:46)
文章代碼(AID): #1C3boSZs (Office)
文章代碼(AID): #1C3boSZs (Office)