Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What Column am I In?
Message
From
25/08/2000 04:13:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00406230
Message ID:
00409108
Views:
53
>It almost worked....
>
>Here's what I tried:
>
>I put colrule(varread()) in the Field Validation Rule of column ADDRESS_LINE_ONE_TX, and colrule.prg looks like this:
>
>  parameter cColName
>  cValue = proper(eval(cColName))
>  do case
>    case cColName = 'ADDRESS_LINE_ONE_TX'
>    ? 'Column Name - ' + proper(cColName)
>    ? 'Column Value - ' + cValue
>    replace &cColName with cValue
>  endcase
>return .t.
>
>When I make a change in the column, I now get an endless loop. I think VFP is constantly replacing the field. Can you think of a way to make it just replace once?
>
>Thanks more!


Replace is causing field validation to retrigger. One way to prevent is to check value and do no replace if it satisfies as Cheryl suggested already. In that case at most 2 levels of procedure calls would occur.
OTOH at times data needs to be validated based on more than one field. And as I understand you want to do silent validation-correction behind the scenes. Then use table validation. You wouldn't need varread then. Something like this :
* Stored procedure
* Table validation for Table1 : myTable1CheckRow() 
function myTable1CheckRow
local ix
scatter name oVerifier
for ix=1 to fcount()
 myTable1ColCheck(field(ix))
endfor
gather name oVerifier
* Further rowwise check

function myTable1ColCheck
lparameters tcColName
do case
 case inlist(tcColName,'FIRST_NAME','LAST_NAME','TITLE')
  store proper(eval('oVerifier.'+tcColName)) to ('oVerifier.'+tcColName)
*....
 otherwise
*...
endcase
If nonbuffered would fire with every field change but would benefit in buffering modes and called once per row change.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform