>Once again with correct pre tags:
>
>2 ways I can think of. You can do:
>SELECT COUNT(*) Kount FROM AllFunctions ;
> Where FunName = ThisFrom.txtFunName.Value ;
> into cursor crsKount
>if crsKount.Kount > 1
>else
>endif
>If that is not fast enough, try this:
>lparameter tcFunName
>if vartype(tcFunName) <> "C" or empty(tcFunName)
> return .f.
>endif
>if not used('AllFun_2')
> use AllFunctions again in 0 alias AllFun_2
>endif
>local lnSelect
>lnSelect = select()
>select AllFun_2
>set order to FunName
>seek upper(lcFunName)
>select (lnSelect)
>return eof('AllFun_2')
Mark,
We have the similar code in our classes, but I realized, it is not sufficient, since it doesn't check for buffered changes.
Basically, there should be two checks: one in textbox valid (or lostfocus). Another in the save method of the form. If I make this tag to be candidate, the save part would be covered by trapping errors on TableUpdate. I'm thinking, that the best way to check uniqueness on the buffered table is to use COUNT FOR upper(FunName)==upper(m.lcFunName) to lnCheck
If lnCheck>1 && This is a duplicate
AFAIK, COUNT FOR works for buffered table. I think, it would be slow, though.
I should also set deleted off before count and back to original settings after count.
What do you think?
If it's not broken, fix it until it is.
My Blog