Hi Jay,
On the way home I figured this out. I will need bunch of local variables, so in my scan loop I would do something like:
lcccrctown=ccode+rcode+town
lcMinDate=record_fm
etc
scan &lcFor
if ccode+rcode+town = lcccrctown
lcMinDate=min(record_fm,lcMinDate)
...
else
replace .. in FilingDate
lcMinDate = record_fm
lcccrctown=ccode+rcode+town
endif
endscan
This way I would not need to use replace on each scan, I can properly work with Notes field, etc.
>>Hi everybody,
>>
>>I think, it's one of the bad day for me... Here is the problem, which I currently can not figure out a solution:
>>
>>As soon as user moves focus to another field on the screen, I need to update another table with the minimum date for the specific town. In my "parent" table could be several records for one town. In the "child" table, there is only one record for this week for this town. I don't want to use select statement, since data are not saved yet.
>>
>I reformatted one condition -- which seems a pattern for the rest:
>
>FilingDate.record_fm with ;
> iif(!empty(FilingDate.record_fm) ;
> and BatchCntrl.record_fm<=FilingDate.record_fm, ;
> BatchCntrl.record_fm, ;
> FilingDate.record_fm)
>
>
>I'm not sure if this is your problem, but I think it doesn't handle one case properly. If the FilingDate.record_fm is empty and BatchCntrl.record_fm is not, the function returns the FilingDate value, which is empty.
>
>One thought comes to mind. This will ensure that you have a non-empty value if one is available in either table:
>
>
>FilingDate.record_fm with ;
> iif (NOT EMPTY (MIN (FilingDate.record_fm, BatchCntrl.record_fm)), ;
> (MIN (FilingDate.record_fm, BatchCntrl.record_fm)), ;
> (MAX (FilingDate.record_fm, BatchCntrl.record_fm)))
>
>
>That pattern can then be applied to the entire statement.
>
>HTH,
>
>Jay
If it's not broken, fix it until it is.
My Blog