Hi experts
When updating a Field of the current Key (not the primary key) I feel a bit strange.![:o :o]()
Have a look at that Code
TestRec.SETCURRENTKEY("First Name");
TestRec.SETFILTER("First Name",'M*');
MESSAGE('No. of Records to modify %1',TestRec.COUNT);
IF TestRec.FINDSET THEN REPEAT
TestRec."First Name" := 'James';
TestRec.MODIFY(FALSE);
NoOfModifyRecords += 1;
UNTIL TestRec.NEXT = 0;
MESSAGE('No of Records modified t %1',NoOfModifyRecords);
Depending on the underlying data, there might be 5 Records to modify, but the loop is exited after the first one.
Many times I've seen code, using a 2. instance of the same record, doing the MODIFY on that 2. instance.
Not bad, but how about using the parameters for FINDSET?
This seems to work like a charm. Any caveats with that? Help for the FINDSET function is IMHO a bit hard to understand.
Btw: I know I could have used MODIFYALL, but just for that simple example.
TestRec.SETCURRENTKEY("First Name");
TestRec.SETFILTER("First Name",'M*');
MESSAGE('No. of Records to modify %1',TestRec.COUNT);
IF TestRec.FINDSET(TRUE,TRUE) THEN REPEAT
TestRec."First Name" := 'Cindy';
TestRec.MODIFY(FALSE);
NoOfModifyRecords += 1;
UNTIL TestRec.NEXT = 0;
MESSAGE('No of Records modified t %1',NoOfModifyRecords);
Thanks a lot for your help.
Thomas
When updating a Field of the current Key (not the primary key) I feel a bit strange.

Have a look at that Code
TestRec.SETCURRENTKEY("First Name");
TestRec.SETFILTER("First Name",'M*');
MESSAGE('No. of Records to modify %1',TestRec.COUNT);
IF TestRec.FINDSET THEN REPEAT
TestRec."First Name" := 'James';
TestRec.MODIFY(FALSE);
NoOfModifyRecords += 1;
UNTIL TestRec.NEXT = 0;
MESSAGE('No of Records modified t %1',NoOfModifyRecords);
Depending on the underlying data, there might be 5 Records to modify, but the loop is exited after the first one.
Many times I've seen code, using a 2. instance of the same record, doing the MODIFY on that 2. instance.
Not bad, but how about using the parameters for FINDSET?
This seems to work like a charm. Any caveats with that? Help for the FINDSET function is IMHO a bit hard to understand.
Btw: I know I could have used MODIFYALL, but just for that simple example.
TestRec.SETCURRENTKEY("First Name");
TestRec.SETFILTER("First Name",'M*');
MESSAGE('No. of Records to modify %1',TestRec.COUNT);
IF TestRec.FINDSET(TRUE,TRUE) THEN REPEAT
TestRec."First Name" := 'Cindy';
TestRec.MODIFY(FALSE);
NoOfModifyRecords += 1;
UNTIL TestRec.NEXT = 0;
MESSAGE('No of Records modified t %1',NoOfModifyRecords);
Thanks a lot for your help.
Thomas