Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing records in file that appear in another

Status
Not open for further replies.

comsources

Vendor
May 18, 2003
3
0
0
US
I'm sure that this is easy and I'm just missing it, but I can't figure out how to easily remove records in file A that also appear in File B. I only want them in File B, but there are too many to remove manually.

Thanks,
Jack
jack@ZIPPYcomsources.com
remove zippy to send a message.
 
I noticed several days have gone by and nobody stepped up to answer your question for you. I've avoided it because it can be so complex to do this. The concept isn't too difficult to explain, it's taking the time to basically write the code to show you.

I've got time to explain the concept today. I'll help with the code if you need it.

You need to create a script in file A. This script needs to verify a match in file B, if there is a match it deletes the current record and moves on to the next. The match is going to be done through a relationship that you need to set up. The script needs to be a looping script that starts at the beginning and exits after it has looked at each record. Be sure you are working in a back up file to create the script.

Something like this:

user abort on (for testing, you want to be able to stop the looping if you've made a mistake.
Go to first record
Set Field(Start, Status(current record number)
Set Field( Next, Start + 1)
Loop
if(name = file b:name)
delete current record
end if
go to record(Next) (next is a field to keep track of where you are going next)
exit loop if(currentfoundcount> Next
Set Field(Next, Next + 1)
end loop

This needs tweeking but it's a start. The Next field is counting the record number so the script knows which record to go to next and if it's time to exit the loop or not. The script is saying that if the currentfoundcount or the number of found records cannot exceed Next + 1. So when Next + 1 exceed the number of found records, exit the loop.

I hope this helps for now.

Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top