Jump to content

How To Create A Specific Number Of Duplicate Records


Barrettb

This topic is 6329 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Can someone please update this to make sense for version 7.xx and up ?

Their script steps and associated syntax do not match our version and even the article itself seems to contradict itself.

http://tinyurl.com/w8qcq

Answer ID

2654

APPLICABLE TO

FileMaker Pro 4.x, FileMaker Pro 3.x

This solution can be used to create return address labels, to duplicate a specific number of records, or to duplicate individual records a specified number of times. The solution assumes that you have already created the fields and records you wish to duplicate. Also, because this solution adds duplicate records to your database, you may want to apply the solution to a copy of your original database.

Let's Begin:

Step #1 - Create five new fields:

- A number field called ;) Amount of Duplicates

The 'Amount of Duplicates' field is where you will enter the amount of duplicate records you wish to create for each record.

- A number field called: Record Number

The 'Record Number' field will be used to give each record a unique record ID.

- A global field(number) called: Global Match For Duplicates

The 'Global Match For Duplicates' field will be used in a comparison between it and the 'Amount of Duplicates' field. If they do not match, a duplicate will be created. If they do match, it will go to the next record to be duplicated.

- A global field(number) called: Global Match For Records

The 'Global Match For Records' field will hold the number of the next record to be duplicated.

- A text field called: Original Marker

The 'Original Marker' field is used to mark the original record before it is duplicated.

Step#2- The Script

The following script will use the fields we have made to create the duplicate records that we need. Between several of the script steps will be comments describing what the script is doing at that particular point:

Set Error Capture [On]

Find All

Replace [No dialog,"Record ID", "Serial numbers"]

Go to Record/Request/Page [First]

Copy [select, "Record ID"]

Enter Find Mode [ ]

Paste [select,"Record ID"]

Perform Find [ ]

COMMENT: The script steps above prepare our database to create duplicates. So that the solution will run from beginning to end without interruption, we have Set Error Capture to On. This will prevent any error massaging from FileMaker Pro 3.0 or 4.0 to appear while the script is running. It will then find all of the records to be duplicated.

Each record must have a unique ID. This is what our 'Replace' step is doing. Once each record has its unique ID, we will copy the number from our Record ID field and perform a find for the record which has that number. This will make it the first record the only record in our found set.

Go to Record/Request/Page [First]

Set Field ["Global Match For Records", "Record ID + 1"]

Set Field ["Original","X"]

Set Field ["Global Match For Duplicates", "1"]

Loop

If["Amount of Duplicates <> Global Match For Duplicates"]

Duplicate Record/Request

Comment: The script steps above will go to the first record in our found set. The found set should be only one record. We then will mark the record as our original with an 'X'. We will then set our field called 'Global Match For Records' to the 'Record ID' number plus 1. This number is the unique ID of the next record. Our Set Field script then sets our 'Global Match For Duplicates' field to the number 1 for the purpose of comparing this number to the number found in our 'Amount of Duplicates' field. If the numbers do not match, a duplicate record will be created.

Clear [select, "Original Marker"]

Set Field ["Global Match For Duplicates", "Global Match For Duplicates +1"]

Comments: Once the duplicate is made, we will clear the 'X' out of the 'Original Marker' field in our duplicate and increase the number in our 'Global Match For Duplicates' field by 1. This number will increase until the number matches the number inside of our 'Amount of Duplicates' field.

Else

Set Field ["Global Match For Records", "1"]

Copy [select,"Global Match For Records"]

Enter Find Mode [ ]

Paste [select, "Record ID"]

Perform Find [ ]

Go to Record/Request/Page [First]

Set Field ["Original Marker","X"]

Set Field ["Global Match For Records". "Record ID + 1"]

If ["Status(CurrentFoundCount) = 0"]

Find All

Exit Script

End If

End If

End Loop

Comments: The Else script step, and the script steps below it, are the actions which will take place if the 'Amount of Duplicates' field matches the 'Global Match For Duplicates' Field. The steps will first set our 'Global Match For Records' field back to 1, so that it will be ready for the next batch of duplicates. We will then copy the number that is in the 'Global Match For Records'. Remember, this field will hold the next record ID. This number is pasted into the 'Record ID' field while in Find Mode and will find the one record with that ID. The found record will then be marked as the original and our 'Global Match For Records' field will be set for the next ID to search for in our database. After it goes through all of the records, our find should give us a result of zero records found. If this is the case, the script will find all of the records created and exit the script.

How to delete the duplicates when you are done:

After you are done using the script, perform a find for all of the records marked with an 'X' inside of the field called Orignal Marker and omit them. You should then have all of the duplicates created as your found set. Select Delete All from the Mode menu. This will leave you with all of your original records. Again, to avoid deleting all of your records by accident, it is recommended that you apply this solution to a copy of your original database.

Link to comment
Share on other sites

Yes the "Label Generator" file looks like it may be the viable solution. I may have tried to be too generic with may original post ref. address labels.

Exactly what I'm doing is attempting a quick down and dirty barcode solution.

I have a products database with unique product codes or part numbers.

Using Code 39 font I intend to convert the product code into barcode and print on the Avery labels.

These will be put on items that don't have barcodes at our massive glorified "garage sale" at our warehouse. The ladies did the first big sale all manually along with using browser based POS ....

I built a quick and dirty POS solution in FM (since my search for one produced no fruit) that uses the product database, will allow scan of the barcode into the "product code" field in the "order items" portal, writes a TAB and jumps to next field.....

It looks like I should be able to adapt the donated Label Generator file. :yay: I will get on it today. Our barcode scanner is coming along with a Linksys bridge to make all this stuff mobile....fun

Another side twist to this is that if I find the sheet labels too expensive or problematic, I did get a vers. 8.5 upgrade last night that will let me run a copy on Windows. So who cares....well we do have the Zebra LP 2844 thermal printers and it turns out those yahoos only wrote the fricken drivers for windows ! :bang:

PS the most extensive smilies I've seen LOL

in case somebody is local here is google map for big sale sometime next month

http://handmade-paper.us/contact.shtml

Thanks,

Barrett

Link to comment
Share on other sites

This topic is 6329 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.