Hi guys,
there's something confusing happens in my app, I have no clue at all:
txtOne txtTwo txtSumTwo txtTotal
1000 0 0 1000
1500 500 500 2000
txtONe = control source: txt1 in the underlying query
txtTwo = control source: txt2 in the underlying query
txtSumTwo = control source : sum([txtTwo])
Sub txtTwo_AfterUpdate()
DoCmd.RunCommand acCmdSaveRecord
me.refresh
If isnull([txtTwo]) or txtTwo = 0 then
txtTotal = txtOne
Else
txtTotal = txtOne + txtSumTwo
End if
End Sub
I try to set a break, and step into the code, it does follow the right track.
Inside the code, when I hoover on top of each variable,
(insertion point in the record 2),
txtTwo(= 500)
so it goes to Else statement
txtTotal (=1500)=txtOne(=1500) + txtSumTwo(=500)
Stepping out of the code and back to the form, yes....txtTotal shows 2000
But, if I try to change again, after update, txtTotal calculation doesn't work again (txtTotal = txtOne)
Isn't it supposed to work just like when you step into the code?
I try to test out how the procedure really works without stepping into the code by displaying a msgbox.
I set in the txtTwo_afterupdate()
docmd.runcommand accmdsaverecord
me.refresh
If...Then... (as above)
msgbox txtTotal
I notice, after tabbing out from txtTwo, the message box is displayed, then txtTwo is blinking meaning it's being refreshed.
From this, seems like the procedure is executed in reverse,
msgbox txtTotal
me.refresh
How could it happen? I'm totally lost....
Any idea?
Thanks ahead,
Tin Tin
there's something confusing happens in my app, I have no clue at all:
txtOne txtTwo txtSumTwo txtTotal
1000 0 0 1000
1500 500 500 2000
txtONe = control source: txt1 in the underlying query
txtTwo = control source: txt2 in the underlying query
txtSumTwo = control source : sum([txtTwo])
Sub txtTwo_AfterUpdate()
DoCmd.RunCommand acCmdSaveRecord
me.refresh
If isnull([txtTwo]) or txtTwo = 0 then
txtTotal = txtOne
Else
txtTotal = txtOne + txtSumTwo
End if
End Sub
I try to set a break, and step into the code, it does follow the right track.
Inside the code, when I hoover on top of each variable,
(insertion point in the record 2),
txtTwo(= 500)
so it goes to Else statement
txtTotal (=1500)=txtOne(=1500) + txtSumTwo(=500)
Stepping out of the code and back to the form, yes....txtTotal shows 2000
But, if I try to change again, after update, txtTotal calculation doesn't work again (txtTotal = txtOne)
Isn't it supposed to work just like when you step into the code?
I try to test out how the procedure really works without stepping into the code by displaying a msgbox.
I set in the txtTwo_afterupdate()
docmd.runcommand accmdsaverecord
me.refresh
If...Then... (as above)
msgbox txtTotal
I notice, after tabbing out from txtTwo, the message box is displayed, then txtTwo is blinking meaning it's being refreshed.
From this, seems like the procedure is executed in reverse,
msgbox txtTotal
me.refresh
How could it happen? I'm totally lost....
Any idea?
Thanks ahead,
Tin Tin