mfaqueiroz
Registered User.
- Local time
- Today, 05:33
- Joined
- Sep 30, 2015
- Messages
- 125
Hi, everyone!
I've two tables: dictionary and InputTable. The table dictionary have 2202 entries and the InputTable 65536.
I've a key that is formed by 3 fields of this tables, the ideia is to look on dictionary an row with the same key and then write on InputTable the description that is on dicionary.
I've write one code for this, but it is very very slow is taking almost 4 hours to finish this task. Do you have any suggestion to optimize my code?
Sub writeonInputTable()
Dim key1 as string
Dim key2 as sting
Dim description as string
Set dbs =DBEngine(0)(0)
Set dictionary= dbs.OpenRecordset("Dic",DB_OPEN_DYNASET)
Set InputTable= dbs.OpenRecordset("Input",DB_OPEN_DYNASET)
dictionary.MoveFirst
Do While not Dicionary.EOF
Key1=dictionary.Fields(1).Value & dictionary.Fields(2).Value & dictionary.Fields(3).Value
Description=dictionary.Fields(4)
InputTable.MoveFirst
Key2=InputTable.Fields(1).Value & InputTable.Fields(2).Value & InputTable.Fields(3).Value
If Key1=Key2 then
InputTable.Edit
InputTable.Fields(4)=Description
InputTable.Update
End if
InputTable.MoveNext
Loop
dictionary.MoveNext
Loop
End Sub
I really appreciate your help,
I wish everyone a happy new year!

I've two tables: dictionary and InputTable. The table dictionary have 2202 entries and the InputTable 65536.
I've a key that is formed by 3 fields of this tables, the ideia is to look on dictionary an row with the same key and then write on InputTable the description that is on dicionary.
I've write one code for this, but it is very very slow is taking almost 4 hours to finish this task. Do you have any suggestion to optimize my code?

Sub writeonInputTable()
Dim key1 as string
Dim key2 as sting
Dim description as string
Set dbs =DBEngine(0)(0)
Set dictionary= dbs.OpenRecordset("Dic",DB_OPEN_DYNASET)
Set InputTable= dbs.OpenRecordset("Input",DB_OPEN_DYNASET)
dictionary.MoveFirst
Do While not Dicionary.EOF
Key1=dictionary.Fields(1).Value & dictionary.Fields(2).Value & dictionary.Fields(3).Value
Description=dictionary.Fields(4)
InputTable.MoveFirst
Key2=InputTable.Fields(1).Value & InputTable.Fields(2).Value & InputTable.Fields(3).Value
If Key1=Key2 then
InputTable.Edit
InputTable.Fields(4)=Description
InputTable.Update
End if
InputTable.MoveNext
Loop
dictionary.MoveNext
Loop
End Sub
I really appreciate your help,
I wish everyone a happy new year!
