Event programming

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


--- 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]
Hello,

In part master file I added three additional fields:
PartWidth
PartHeight
PartArea = PartWidth * PartHeight

Question is how to do this with customization?
If
I'm using TextChanged event PartArea value is changed until focus is on
PartWidth or PartHeight field, when focus leaves PartWidth field eg.
PartArea field value is retored to previous.

How correctly code event:
if changed PartWidth and changed PartHeight then
  PartArea.text = PartWidth * PartHeight
end if

thanks,
tom







[Non-text portions of this message have been removed]
Tom

I don't understand the need to determine focus and use it any way to trigger the math to recalc & update Area. (??)

Why not just trigger after any change to Height or Width values?

Also, why use TextChanged when you are dealing with what are inherently numeric values?

Last dumb question: Native dimensional inventory fields can't cover at least some of your needs? (We don't use dim inventory - so I really don't know.)

Rob

--- On Fri, 11/28/08, tomas paulavicius <tpaulavicius@...> wrote:
From: tomas paulavicius <tpaulavicius@...>
Subject: [Vantage] Event programming
To: vantage@yahoogroups.com
Date: Friday, November 28, 2008, 1:27 PM











Hello,



In part master file I added three additional fields:

PartWidth

PartHeight

PartArea = PartWidth * PartHeight



Question is how to do this with customization?

If

I'm using TextChanged event PartArea value is changed until focus is on

PartWidth or PartHeight field, when focus leaves PartWidth field eg.

PartArea field value is retored to previous.



How correctly code event:

if changed PartWidth and changed PartHeight then

  PartArea.text = PartWidth * PartHeight

end if



thanks,

tom



[Non-text portions of this message have been removed]
ok.

Q: how to make triger, that changes field2 value, when field1 value is changed?
I used event TextChanged and code something like:
sub field1_TextChanged(params....)
 field2.text = some value
end sub

but problem is when cursor stands on field1 and it's value is changed, automaticaly field2 value is changed to 'some value', but when cursor leaves field1, field2 value is automaticaly restored that was previous.

tom






[Non-text portions of this message have been removed]
Your pseudo code snippet: field2.text = some value

- suggests you are only changing the custom text control displayed text.

If so, that is why it reverts when focus changes. You must make the epidataview(table.field, row) = some value.

With VB, some table.fields also require an otrans.update() statement after setting their temp state value. (You have to force the data write.)

Why? No idea. Just seems to be the case occasionally.

If you include you're real (complete) code, it would be easier to help.

Theoreticals leave too much unknown & in programming, exact syntax is everything.

Rob

--- On Sat, 11/29/08, tomas paulavicius <tpaulavicius@...> wrote:
From: tomas paulavicius <tpaulavicius@...>
Subject: Re: [Vantage] Event programming
To: vantage@yahoogroups.com
Date: Saturday, November 29, 2008, 7:54 AM

ok.

Q: how to make triger, that changes field2 value, when field1 value is changed?

I used event TextChanged and code something like:

sub field1_TextChanged( params... .)

 field2.text = some value

end sub



but problem is when cursor stands on field1 and it's value is changed, automaticaly field2 value is changed to 'some value', but when cursor leaves field1, field2 value is automaticaly restored that was previous.



tom



[Non-text portions of this message have been removed]
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]