January 18, 200521 yr I am having a problem with the following script. I only want the first occurance of duplicate records to print. Show All Records Sort Records [invfile::PartNO]Restore/No Dialog GoTo Record/Request/Page [first] Set Field [invfile::DupCalc(Global); invfile::PartNo Loop Go To REcord/Request/Page [Next, Exit after last] Set Field [invfile::DupCalc; invfile::PartNo] If [invfile::partno=invfile::Dupcalc] Omit REcord End if End Loop
January 19, 200521 yr Add an Exit Loop statement inside the conditional If-End If statements...because you said you only wanted to show the first occurrence of a duplicate.
January 19, 200521 yr When using "go to next" and "omit" together in a loop, you must separate them with an "else," or you'll end up skipping records. I.e., your script omits a record, which puts you on the next record... then it goes to next record... so the record right after the omit is left out of the processing! Notice in this script I initialize the global field to "" (empty). Thus, the first record does NOT equal the global, so we set the global to that record's PartNo and off we go. The Exit Loop If is just a safety measure so we don't get stuck or lose the last record by mistake. Show All Sort Go To Record [first] Set Field [ invfile::DupCalc(Global); "" ] Loop If [invfile::partno = invfile::Dupcalc] . Omit Record Else . Set Field [invfile::DupCalc; invfile::PartNo] . Go To Record/Request/Page [Next, Exit after last] End if Exit Loop If [ Get ( RecordNumber ) = Get ( FoundCount ) ] End Loop
January 20, 200521 yr Author Eureka! It works! This has kicked my rear for a day and a half. I could always omit the second record but not any more that followed. Thank You, Thank You. Ain't this a great Forum. Ivan
Create an account or sign in to comment