Hi all,
I have a table with about 1,2million records. I get an Excel list of about 35000 weekly, using which the table has to be updated: the records, that exist get fields updated, the ones that are new have to be added.
What is the fastest way to do this?
I'm trying with this code, but it's awfully slow, even if I read the update ranges into memory:
Any ideas? (I'm a beginner with Access.)
I have a table with about 1,2million records. I get an Excel list of about 35000 weekly, using which the table has to be updated: the records, that exist get fields updated, the ones that are new have to be added.
What is the fastest way to do this?
I'm trying with this code, but it's awfully slow, even if I read the update ranges into memory:
Code:
Set cn = CurrentProject.Connection
Set Rs = New ADODB.Recordset
Rs.Open "Select * from tbl_TTextract", cn, adOpenDynamic, adLockOptimistic
i = 2
Do While i < lr_2 + 1 'update
With Rs
On Error Resume Next 'if empty, .movefirst errors out
.MoveFirst
On Error GoTo 0
'MsgBox .Fields("CustomerNr").Value
.Find "[ID]='" & myupdaterng(i, 1) & "'"
If (.BOF = True) Or (.EOF = True) Then 'not found
.AddNew
.Fields("ID") = myupdaterng(i, 1)
'etc, other fields
.Update
Else 'found -> update
.Fields("Status") = myupdaterng(i, 5)
'etc, other fields
.Update
End If
End With
i = i + 1
Loop
Any ideas? (I'm a beginner with Access.)