silentwolf
Well-known Member
- Joined
- May 14, 2008
- Messages
- 1,216
- Office Version
- 2016
Hi guys,
I am trying to update several fields in a access table but have about 50 different criterias and am not sure how to set it up correctly.
Following situation.. I need to look in a field and find a part of a string within the string then update this and other fields according to the criteria.
At present I am realising it with a update Query like so
Sub Mueller()
Dim rcsKonto As Recordset
Dim db As Database
Set db = CurrentDb
Set rcsKonto = db.OpenRecordset("SELECT * FROM tbl_CSV WHERE Umsatztext LIKE'*Müller*'", dbOpenDynaset)
Do Until rcsKonto.EOF
rcsKonto.Edit
rcsKonto.Fields("Feld11").Value = "IG Erlöse"
rcsKonto.Fields("Umtext").Value = "Müller"
rcsKonto.Fields("Gegenkonto").Value = "4100"
rcsKonto.Update
rcsKonto.MoveNext
Loop
End Sub
this works but the problem is that I got about 50 or more those kind of statements and when I am trying to run all at once it gets quite slow..
How could I do it better to realise all my search criterias in one go and still have a good speed plus keep it quite clear to get around the code.
Is it better using custom functions to update the fields or a class module or or or...
Hope someone can give me a hint or a direction for me to get it better sortet.
Many thanks for your input!!!
Albert
I am trying to update several fields in a access table but have about 50 different criterias and am not sure how to set it up correctly.
Following situation.. I need to look in a field and find a part of a string within the string then update this and other fields according to the criteria.
At present I am realising it with a update Query like so
Sub Mueller()
Dim rcsKonto As Recordset
Dim db As Database
Set db = CurrentDb
Set rcsKonto = db.OpenRecordset("SELECT * FROM tbl_CSV WHERE Umsatztext LIKE'*Müller*'", dbOpenDynaset)
Do Until rcsKonto.EOF
rcsKonto.Edit
rcsKonto.Fields("Feld11").Value = "IG Erlöse"
rcsKonto.Fields("Umtext").Value = "Müller"
rcsKonto.Fields("Gegenkonto").Value = "4100"
rcsKonto.Update
rcsKonto.MoveNext
Loop
End Sub
this works but the problem is that I got about 50 or more those kind of statements and when I am trying to run all at once it gets quite slow..
How could I do it better to realise all my search criterias in one go and still have a good speed plus keep it quite clear to get around the code.
Is it better using custom functions to update the fields or a class module or or or...
Hope someone can give me a hint or a direction for me to get it better sortet.
Many thanks for your input!!!
Albert