Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Better To Update .Value or view field?
Message
From
14/05/2001 12:04:41
 
 
To
14/05/2001 11:25:47
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00506836
Message ID:
00506874
Views:
17
Hi!

Yes, the refresh() takes a value from the control source immediately. You should not change the value of the control, you should change the value in the source, as well as take values from there. Example based on your code:
WITH THIS

  IF .Value > 0 && you can use also "eval(.ControlSource)" that will take value from field instead

   * parent is just the form
   IF .PARENT.ToLife = .T.


      replace (.PARENT.ToLife.ControlSource) with .F.
      .PARENT.ToLife.Refresh()

   ENDIF

  ENDIF
ENDWITH
Above will work correctly and use OOPish way - no direct acces to data but acces through control only.

HTH.

>Dear Y'all,
>
>Sometimes my users want me to update the contents of another field based upon what they did with the current field. For this company, they are inputting the parameters for the person to buy an annuity and the annuity can either be "To Life" (a checkbox) or so many Years and Months. They often do a printout based on one of the two but then come back later and do a different one. For example, the first printout is payable "To Life" (for life) and they print it for the customer. A week later the customer wants to see how much the annuity would cost to purchase if they just had it pay "20 years and 0 months" so they go back in to edit the printout. What they want me to have the program do is that if they enter a value in Years, it automatically unchecks "To Life" and visa versa (there are actually multiple fields they want nuked so it's valid for them to ask that this be done automatically).
>
>So here's the question: I originally thought that the best way to work with objects bound to view fields would be to always change the .Value of the object and let that value then "ripple" down to the field. So in my example, if the user entered in "20" to the Years field, code in my VALID() or INTERACTIVECHANGE() of that object did something like:
>
>WITH THIS
>
>IF .Value > 0
>
> * parent is just the form
> IF .PARENT.ToLife = .T.
>
> STORE .F. TO .PARENT.ToLife.Value
> .PARENT.ToLife.Refresh()
>
> ENDIF
>
>ENDIF
>
>But this did not work correct. So I decided to instead do
>
>IF .Value > 0
>
> SELECT v_Annuity
>
> IF ToLife = .T.
> REPLACE ToLife WITH .F.
> .PARENT.ToLife.Refresh()
> ENDIF
>
>ENDIF
>
>Somewhere I read that it is better OOPS to always work with the objects as opposed to changing the fields directly. But maybe I am thinking of .Refresh() wrong - I sortof thought that if I changed .Value, that a .Refresh() would also update the view; but maybe it doesn't - maybe Refresh() only updates the control with whatever is in the control source?
>
>Can anyone confirm this behaviour?
>
>Albert
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform