Compare the same

bRahms
bRahms Member Posts: 44
Hi again,

we've got a problem, once again. It's probably a quite easy problem to fix, but we just don't get it to fix it. The code given below i'm sure isn't correct, because you search the DossierID and then again you search for the same Dossier ID. What we want is, when he found twice the same DossierID (which isn't the primary key), they only show that one on our report.
So for example:
Dossier ID
1
2
5
8
9
2
9

The ones who should be shown on the report are just 2 and 9. How to? Any help would be thankful.
recrecidive.RESET;
recrecidive.SETCURRENTKEY(DossierID);
recrecidive.SETFILTER(DossierID,'=%1', recrecidive.DossierID);
IF recrecidive.FIND('-') THEN
  REPEAT 
     recrecidive.SETFILTER(DossierID,'=%1', recrecidive.DossierID);
    IF recrecidive.FIND('-') THEN
      REPEAT 
            IF DATE2DMY(recdossier.Opstartdatum,2) >= DATE2DMY(recdossier.Afsluitdatum,2) THEN BEGIN
              IF DATE2DMY(recdossier.Opstartdatum,1) >= DATE2DMY(recdossier.Afsluitdatum,1) THEN BEGIN
              END ELSE BEGIN
              EXIT;
            END END;

      UNTIL recrecidive.NEXT = 0;
  UNTIL recrecidive.NEXT = 0;

Comments

  • lubost
    lubost Member Posts: 633
    I think that your code is completely wrong, because you changes the record position of "recrecidive" inside repeat ... until loop. Of course it is possible but for special reason (I don't know such).
  • Saint-Sage
    Saint-Sage Member Posts: 92
    You need a second instance of the table, such as recrecidive2.

    So

    inside your recrecidive REPEAT do a

    recrecidive2.RESET;
    recrecidive2.SETFILTER(the same filters you had in the outter loop)
    REPEAT

    IF recrecidive2.whateverdate > recrecidive.whateverdate
    THEN you know you have the newest date

    UNTIL recrecidive2.NEXT = 0;

    UNTIL outter loop processed


    I hope this helps, have a great day!

    No one loves you like the one who created you...
  • DenSter
    DenSter Member Posts: 8,307
    One way to go:
    Dataitem for recrecidive2.
    Then in OnAfterGetRecord:
    LocalVariable_recrecidive2.RESET;
    LocalVariable_recrecidive2.SETRANGE(DossierID,recrecidive2.DossierID);
    IF LocalVariable_recrecidive2..COUNT = 1 THEN
      CurrReport.SKIP;
    
    So it only displays duplicate values, and skips unique ones. I'm just writing this off the top of my head, so you'll probably have to tweak it a little bit.
  • bRahms
    bRahms Member Posts: 44
    we did it kind of like saint-sage said, thanks for that. but now we've got problems when einddatum isn't filled in (not all the dossierID's have an einddatum). Then he says the date is invalid
    recrecidive.RESET; 
    recrecidive.SETCURRENTKEY(DossierID); 
    IF recrecidive.FIND('-') THEN REPEAT
    
        recdossier.RESET;
        recdossier.SETCURRENTKEY(DossierID);
        recdossier.SETFILTER(DossierID,'=%1', recrecidive.DossierID);
        IF recdossier.FIND('-') THEN REPEAT
    
          recrecidive2.RESET;
          recrecidive2.SETFILTER(DossierID,'=%1', recdossier.DossierID);
          IF recrecidive2.FIND('-') THEN REPEAT
          IF DATE2DMY(recrecidive2.Begindatum,2) > DATE2DMY(recrecidive.Einddatum,2) THEN BEGIN
           MESSAGE('hi' + format(recrecidive2.dossierID));
          END;
          UNTIL recrecidive2.NEXT = 0;
        UNTIL recdossier.NEXT = 0;
      UNTIL recrecidive.NEXT = 0;
    
  • Mbad
    Mbad Member Posts: 344
    ofcourse
  • bRahms
    bRahms Member Posts: 44
    we did know the offcourse as well, but we don't know how to fix it.. if it's fixable
  • DenSter
    DenSter Member Posts: 8,307
    So you have the recrecidive table, through which you loop, then you filter the Dossier table on DossierID, through which you loop, and then for each rec found, you filter a second instance of the recrecidive table, and you filter on DossierID That is a classic example of redundancy :shock:

    Why not set a filter on DossierID directly in the second instance of your recrecidive table? If DossierID is the primary key of the Dossier table, then do Dossier.GET(DossierID) instead, because there is only one record for that ID, and you shouldn't have to loop.

    NAV can only do DATE2DMY if there is a date value, so you should add something to your recrecidive2 loop, something like this:
    IF recrecidive2.FINDSET THEN REPEAT
      IF (recrecidive2.Begindatum = 0D) OR
         (recrecidive2.Einddatum = 0D) THEN BEGIN
        MESSAGE('blank date value found');
      END ELSE BEGIN
        IF DATE2DMY(recrecidive2.Begindatum,2) > 
            DATE2DMY(recrecidive.Einddatum,2) THEN BEGIN
          MESSAGE('hi' + format(recrecidive2.dossierID));
        END ELSE BEGIN
          //program what should happen if the condition is not met
        END;
      END;
    UNTIL recrecidive2.NEXT = 0;