Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Better To Update .Value or view field?
Message
From
14/05/2001 11:25:47
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Better To Update .Value or view field?
Miscellaneous
Thread ID:
00506836
Message ID:
00506836
Views:
51
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
Next
Reply
Map
View

Click here to load this message in the networking platform