Jump to content

number generating scripts that are record independent


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

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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]

=-=-=-=-=-=-=-=-=-=-=-=-=

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 7784 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
 Share

×
×
  • Create New...

Important Information

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