Page 1 of 1

Delete Duplicate records

PostPosted: Tue Apr 04, 2006 2:51 pm
by vegaanders
Hi!
newcomer to FM. have 8 version. Want to delete all duplicate records in a table but cant get the example in the helpfile to work
My table contains of 2 fields
Destination textfield
Rate numberfield
There are a lot of records with the same destination and rate that I want to delete
Please help

PostPosted: Wed Apr 05, 2006 4:01 pm
by John Sindelar
Here is a simple way to do this...

a) Backup your file then find your dupe records.

b) Sort them by their dupe criteria (so that all the duplicates are next to each other).

c) Run the following script. Remember: this only works if your dupes are sorted as described above. If you're in FileMaker 7 or previous, set a global field instead of using the variable in this script. "YourField(s)" below represents the criteria by which you know a record is a dupe. In your case this might be your Destination and Rate appended to each other like this: Destination&rate

Code: Select all
Go to Record/Request/Page [ Last ]
Loop
   Set Variable [ $criteria; Value:YourField(s) ]
   Omit Record
   Loop
      If [ $criteria = YourField(s) ]
          Delete Record/Request [ No dialog ]
      End If
      Exit Loop If [ Get ( FoundCount ) = 0 or $criteria  =?  Far::url ]
   End Loop
   Exit Loop If [ Get ( FoundCount ) = 0 ]
End Loop
Show All Records