How do I 'FIND' a record not based on the primary key?

juanborrasjuanborras Member Posts: 35
Hi there,

I got the table Person( PIN, CODE, FullName ), where PIN is primary key and CODE is defined as a Key (no PK). I want to search by CODE, so I should use:

Person.SETCURRENTKEY( CODE );
Person.CODE = '0001';

IF Person.FIND('=') THEN
MESSAGE('Person found')
ELSE
MESSAGE('Person not found');

Am I missing something? If I have the record 12345678, 0001, John Bear, the 'Person not found' Dialog window appers...

Thanks

Comments

  • CaffaCaffa Member Posts: 15
    I would prefer the following....

    Person.RESET;
    Person.SETCURRENTKEY(CODE);
    Person.SETRANGE(CODE,YourVar);
    IF Person.FIND('-') THEN
    MESSAGE('Person found')
    ELSE
    MESSAGE('Person not found');
  • HalMdyHalMdy Member Posts: 429
    Hi too !

    You have to put a filter on your CODE field, like this :

    Replace line
    Person.CODE = '0001';
    With
    Person.SETFILTER(CODE,'0001');

    And it works !! No ?
  • juanborrasjuanborras Member Posts: 35
    Thanks Caffa, it works!
Sign In or Register to comment.