ms access - loop updates table but also gets system exceeds resources error -


i running loop below in macro. finishes updating table "system resources exceed"... wondering wrong...

or better way of doing it...

dim rst dao.recordset  set rst = currentdb.openrecordset("temp_group")  rst.movefirst until rst.eof   if isnull(rst!avgoft1_discount)      rst.edit      rst!avgoft1_discount = 0      rst.update   end if    if isnull(rst!avgoft2_discount)      rst.edit      rst!avgoft2_discount = 0      rst.update   end if    if isnull(rst!avgoft3_discount)      rst.edit      rst!avgoft3_discount = 0      rst.update   end if    if isnull(rst!avgoft4_discount)      rst.edit      rst!avgoft4_discount = 0      rst.update   end if    rst.movenext loop  set rst = nothing 

it should work no errors, though simplified edit once per record:

dim rst dao.recordset  set rst = currentdb.openrecordset("temp_group")  rst.movefirst until rst.eof   if isnull(rst!avgoft1_discount.value + rst!avgoft2_discount.value + rst!avgoft3_discount.value + rst!avgoft4_discount.value)      rst.edit      if isnull(rst!avgoft1_discount.value)          rst!avgoft1_discount.value = 0      end if      if isnull(rst!avgoft2_discount.value)          rst!avgoft2_discount.value = 0      end if      if isnull(rst!avgoft3_discount.value)          rst!avgoft3_discount.value = 0      end if      if isnull(rst!avgoft4_discount.value)          rst!avgoft4_discount.value = 0      end if      rst.update   end if   rst.movenext loop  set rst = nothing 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

ios - Possible to get UIButton sizeThatFits to work? -