EL_Gringo
Member
- Local time
- Yesterday, 22:37
- Joined
- Aug 22, 2012
- Messages
- 38
I ran into a strange behaviour in a rutine that deletes a line in a table and then generates two values based on DSums. The second DSum allways returns '0'. Putting the Dsums before the delete, they work fine. The code:
A) This gives the problem:
CurrentDb.Execute "DELETE * FROM Table3 WHERE Table3.XY=0;"
MLngInicio = CLng(Forms!Informes_Inicio!FInicio)
MFilter = "(Fecha < " & MLngInicio & ")"
MSumDeber = Nz(DSum("[Importe]", "Table1", MFilter), 0)
MSumHaber = Nz(DSum("[Importe]", "Table2", MFilter), 0)
B) This works fine:
MLngInicio = CLng(Forms!Informes_Inicio!FInicio)
MFilter = "(Fecha < " & MLngInicio & ")"
MSumDeber = Nz(DSum("[Importe]", "Table1", MFilter), 0)
MSumHaber = Nz(DSum("[Importe]", "Table2", MFilter), 0)
CurrentDb.Execute "DELETE * FROM Table3 WHERE Table3.XY=0;"
More strangely even, the above mentioned behaviour ocurrs if there is following code to insert the values MSumDeber and MSumHaber into a new line in Table3 (with a recordset-method). If that code is commented out, the problems ocurrs no matter if I use pattern A or B :banghead:
A) This gives the problem:
CurrentDb.Execute "DELETE * FROM Table3 WHERE Table3.XY=0;"
MLngInicio = CLng(Forms!Informes_Inicio!FInicio)
MFilter = "(Fecha < " & MLngInicio & ")"
MSumDeber = Nz(DSum("[Importe]", "Table1", MFilter), 0)
MSumHaber = Nz(DSum("[Importe]", "Table2", MFilter), 0)
B) This works fine:
MLngInicio = CLng(Forms!Informes_Inicio!FInicio)
MFilter = "(Fecha < " & MLngInicio & ")"
MSumDeber = Nz(DSum("[Importe]", "Table1", MFilter), 0)
MSumHaber = Nz(DSum("[Importe]", "Table2", MFilter), 0)
CurrentDb.Execute "DELETE * FROM Table3 WHERE Table3.XY=0;"
More strangely even, the above mentioned behaviour ocurrs if there is following code to insert the values MSumDeber and MSumHaber into a new line in Table3 (with a recordset-method). If that code is commented out, the problems ocurrs no matter if I use pattern A or B :banghead: