John Weller wrote:
> OK - I want to position the record pointer in a table on a particular record
> based on a primary key if it exists, if not I want an error message. I
> would use the code:
>
> IF SEEK(Thisval, 'MyTable','MyTag')
> *&* Do something
> ELSE
> MESSAGEBOX('That key not found')
> ENDIF
>
> What is the SQL I should use instead?
>
SELECT ThisVal FROM MyTable WHERE MyPK = ThisVal INTO CURSOR temp
IF RECCOUNT("temp") = 0 then
llExists = .F. && doesn't exist
ELSE
llExists = .T. && does exist
ENDIF
* or could be written this way if that's all you needed to do:
llExists = RECCOUNT("temp") > 0
return llExists
This is another scenario where separating your data logic from your
presentation layer is a GOOD thing. That way your UI simple calls IF
THISFORM.OBIZ.ODATA.DoesKeyExist(MyKey) and reacts accordingly.
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.