Check next record in view

amadman114amadman114 Member Posts: 36
Howdy,
I'm trying to make the life of a user easier; currently, they have to set a "commodity code" for each line/record in a form.
The commodity code is chosen based on the information in the description.

I want to create a snippet of code that checks whether the description in the next record(s) is the same as the one which was just set.

This is what I tried:
LtxtDescriptionCheck := Description;

REPEAT
IF LtxtDescriptionCheck = IntrastatJnlLine.Description THEN BEGIN;
  IntrastatJnlLine."Tariff No." :=  LtxtDescriptionCheck;
END;
Rec.NEXT

However, this doesn't work. How can I do this?
Dan

Comments

  • vaprogvaprog Member Posts: 1,141
    Do you really need to check the next line, not the previous one?

    Your code is (I have no words for it), so I just ignore that for my code snippet.

    I'd try
    NexlLineRec.COPY(Rec);
    IF NexlLineRec.NEXT THEN
      IF NextLineRec.Description = Description THEN BEGIN
        // copy from NexlLineRec to Rec whatever you need
      END;
    

    Some problems with your code
    • There is no UNTIL to go with your REPEAT
    • You probably don't want to step away from Rec as you do with Rec.NEXT
    • You seem to try to scan Rec but use IntrastatJnlLine in your compare
    • Assigning Description to "Tariff No." seems strange
Sign In or Register to comment.