Tom
I think you are triggering your number01 calculation too soon.
Just because you entered a value in txtPartijosDydisM2 (which I assume corresponds to number05) & tabbed out of the field doesn't mean that value was actually updated in number05 as the new value for that record.
That is likely why your messagebox.show(m2) still shows the old value.
Proof would be to precede your messagebox.show(m2) line with a messagebox.show(txtPartijosDydisM2.text) line.
If the 1st message box shows your new value (based on what the text box is holding as a temp value) & the second shows the prior value (still based on the un-updated old number05 record value), you'll have isolated your problem.
If that proves true: Instead of a _leave triggered sub, go back to trying an after value changed trigger on txtPartijosDydisM2.
Then set up a forced write of that value to number05:
edv.dataView( edv.Row)( "Number05" ) = txtPartijosDydisM2.text
otrans.update()
THEN follow that with your IF loop to update number01:
if m2 > 0 and vnt > 0 then
edv.dataView( edv.Row)( "Number01" ) = m2 / vnt
oTrans.Refresh( )
end if
All that may be unnecessary though. I don't know why you're trying to trigger number01 recalc & update based upon such selective UI states (the user just tabbed out of the textbox entry field in your case) - but it seems overcomplicated.
You might be better off using an after change EpiNotification triggered sub on number05 (& I assume also ultimately number06).
When EpiNotify's actually work (and they do NOT always work usefully... even in native apps the timing of the notifications isn't always useful to do what you want - and in customized applications, they can be inadvertently & mysteriously deadened entirely), it is the cleanest way to go.
It guarantees the critical data (in this case: number05) has 1st actually been changed (at the db level) & you aren't running into these problematic update & timing issues you seem to be hitting.
Just make sure you include code to prevent row(-1) driven errors if you use EpiNotify's.
Oh yeah: An otrans.refresh() likely just returns txtPartijosDydisM2 to its previous value. That is another way (besides the messageboxes) to infer you haven't yet actually updated number05 before calculating number01 (based upon number05 & 06).
Rob
I think you are triggering your number01 calculation too soon.
Just because you entered a value in txtPartijosDydisM2 (which I assume corresponds to number05) & tabbed out of the field doesn't mean that value was actually updated in number05 as the new value for that record.
That is likely why your messagebox.show(m2) still shows the old value.
Proof would be to precede your messagebox.show(m2) line with a messagebox.show(txtPartijosDydisM2.text) line.
If the 1st message box shows your new value (based on what the text box is holding as a temp value) & the second shows the prior value (still based on the un-updated old number05 record value), you'll have isolated your problem.
If that proves true: Instead of a _leave triggered sub, go back to trying an after value changed trigger on txtPartijosDydisM2.
Then set up a forced write of that value to number05:
edv.dataView( edv.Row)( "Number05" ) = txtPartijosDydisM2.text
otrans.update()
THEN follow that with your IF loop to update number01:
if m2 > 0 and vnt > 0 then
edv.dataView( edv.Row)( "Number01" ) = m2 / vnt
oTrans.Refresh( )
end if
All that may be unnecessary though. I don't know why you're trying to trigger number01 recalc & update based upon such selective UI states (the user just tabbed out of the textbox entry field in your case) - but it seems overcomplicated.
You might be better off using an after change EpiNotification triggered sub on number05 (& I assume also ultimately number06).
When EpiNotify's actually work (and they do NOT always work usefully... even in native apps the timing of the notifications isn't always useful to do what you want - and in customized applications, they can be inadvertently & mysteriously deadened entirely), it is the cleanest way to go.
It guarantees the critical data (in this case: number05) has 1st actually been changed (at the db level) & you aren't running into these problematic update & timing issues you seem to be hitting.
Just make sure you include code to prevent row(-1) driven errors if you use EpiNotify's.
Oh yeah: An otrans.refresh() likely just returns txtPartijosDydisM2 to its previous value. That is another way (besides the messageboxes) to infer you haven't yet actually updated number05 before calculating number01 (based upon number05 & 06).
Rob
--- On Sun, 11/30/08, tomas paulavicius <tpaulavicius@...> wrote:
From: tomas paulavicius <tpaulavicius@...>
Subject: Re: [Vantage] Event programming
To: vantage@yahoogroups.com
Date: Sunday, November 30, 2008, 12:10 PM
Ok, finally I got smth working.
But I've go another problem:
I'm using event "Leave", that trigers event when I leave field with "TAB" or move cursor to another field with mouse.
Default field value is 0, I enter eg. 10, but during event is taken value 0, next time I change valu from 10 to 20 during event is taken value 10.
Why event do not see current value?
I've tried tu use oTrans.Update( ) or oTrans.Refresh( ) but It did not helped..
I add code below:
Private Sub txtPartijosDydisM2_ Leave(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles txtPartijosDydisM2. Leave
      '// ** Place Event Handling Code Here **
       Dim edv As EpiDataView = CType(oTrans. EpiDataViews( "Part"), EpiDataView)
       Dim m2 as Double = CType(edv.dataView( edv.Row)( "Number05" ), Double)
       Dim vnt as Double = CType(edv.dataView( edv.Row)( "Number06" ), Double)
      MessageBox.Show( m2) 'there i can see that is taken previous value
       if m2 > 0 and vnt > 0 then
           edv.dataView( edv.Row)( "Number01" ) = m2 / vnt
           'oTrans.Refresh( )
       end if
   End Sub
Thanks,
Tom
[Non-text portions of this message have been removed]