Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I check of a txt box value has changed
Message
 
To
25/08/1998 10:47:35
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00129277
Message ID:
00129754
Views:
29
>>>>>Is there a fuction to tell me if a text box value has changed during an edit. I show data on a form with all the txt boxes disabled. The user can hit an EDIT command button that then enables all txt boxes and then a SAVE or CANCEL button. I know of several ways to do it programmatily but is there an easy way?
>>>>
>>>>John,
>>>>
>>>>The easiest way I know of is also probably the oldest. In you abstract textbox class, add the property .oldValue.
>>>>
>>>>In the GetFocus() event of the control, add the line:
>>>>
>>>>.oldvalue = .value
>>>>
>>>>Now if the user edits the value, .oldvalue will not be equal to value -- something that is easy to check at any time.
>>>>
>>>>regards,
>>>Aha, he was talking about table data changes, not textbox.value changes ? Then it's easier to use buffering and check oldval() vs value.
>>>-A textbox class could set a flag on.
>>>-Getfldstate(-1)
>>>-Getnextmodified() (Maybe has grid too)
>>>-scatter memvar name beforedit
>>>scatter name afteredit
>>>lDataChanged=compobj(beforeedit,afteredit)
>>>-oldval(), curval()
>>>and so on.
>>>Cetin
>>
>>
>>Thanks for all the replies. I wound up using in the txt box valid:
>>if oldval('table', 'field' ) = txtbox.value ...
>>This allows me to see if that one txt box changed. Any comments?
>If NULLS are allowed this would fail miserably on the first attempt. So you might change it to :lChanged = !(nvl(oldval('field','table'),"")==this.value)To make it a class take the long way at the start :* Mytextbox.lostfocus
>lcField = substr(this.controlsource,rat(".",this.controlsource)+1)
>lcTable = substr(this.controlsource,1,rat(".",this.controlsource)-1)
>lChanged = !(nvl(oldval(lcField, lcTable),"")==this.value)
>* Do whateverBut I suggest preventing valid as method to do this + do you really need to check on every textbox ? (You could put all the code in one method - ie:save.click and use getfldstate()).
>Cetin

I only need to check one field, company, for this during the edit and ask right then if the user wants to use the company address if the company has changed. I also need to check if it is a valid name and do a lookup in a grid (seperate form) if it is not valid or only a partial name.
Beer is proof that God loves man, and wants him to be happy. - Benjamin Franklin
John J. Henn
Previous
Reply
Map
View

Click here to load this message in the networking platform