June 26, 200025 yr I'm writing a script to generate sequential numbers when attached to a button. It works fine in an individual record, but when I open a new record it resets itself to 1. Is there a way to keep the current number from record to record while continually adding on to said number?
June 26, 200025 yr Sequential numbers (serial numbers) are easily set under Define: Fields/Options, and when used, are assigned automatically on the creation of a new record. This would avoid the need for a script. Hope this is useful. Peace Keith M. Davie
June 26, 200025 yr Author I had used that method at first, but then ran into the obstacle of needing to generate multiple numbers per record, so the serial number option wasn't satisfying that need. Sometimes I need 1 or more numbers for an individual record, then on the next record I need the next consecutive number from the previous record.
June 26, 200025 yr quote: Originally posted by smoothdra: I had used that method at first, but then ran into the obstacle of needing to generate multiple numbers per record, so the serial number option wasn't satisfying that need. Sometimes I need 1 or more numbers for an individual record, then on the next record I need the next consecutive number from the previous record. Assuming you have 1 field which stores this number and only 1 number in this field, heres what you can do: Setup a self-relationship by a constant (i.e. a calculation field = 1) and then sort the relationship in descending order by your number field. Now the highest number is the first record in the relationship and you can use "Number = RelationshipName::Number + 1" to get the next highest number. If the numbers are stored in more than one field or multiple numbers are stored in the field. Use the "Max(field1, field2, etc)" in a calculated field to get the highest number in that record. Then base the relationship and other calculations on this field. ------------------ =-=-=-=-=-=-=-=-=-=-=-=-= Kurt Knippel Senior Filemaker Developer http://www.inthescene.com mailto:[email protected] =-=-=-=-=-=-=-=-=-=-=-=-=
June 26, 200025 yr You might want to try using a global field to store the last number used. Then your script could follow these steps: 1) Insert Calculated result of the global field + 1 (called Paste result in older versions) 2) Copy the new result and paste back to global field. Good luck.
June 26, 200025 yr Go to the following website. http://www.databasepros.com/index.html Go to the Tips & Tricks Section and search for the files on Serials. There are a couple of excellent downloads there.
Create an account or sign in to comment