Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Script Talk › How to create a custom index with a sequential number
- This topic has 2 replies, 3 voices, and was last updated 1 year ago by
Daniel Leu.
-
AuthorPosts
-
November 3, 2024 at 4:06 AM #51250
pierrot_rennesParticipantHi,
I have 3700 records from a comic book puzzle collection database
I want to add an index field for classifying boxes according to the collection theme
examples:
Asterix = AST
Lucky Luke = LLK
etc…
I would like this field to have a three-digit sequential number and to be notified if it is already used for a theme
Example: AST001 is already used, I must use AST002
Is a script possible for this kind of request?
Thanks in advanceNovember 3, 2024 at 6:40 PM #51255
BrendanKeymasterThe trickiest part of your request is to be notified if your sequential number has already been used or not. One way achieve that would be to have a Field script loop through all your records, searching for the value that you just entered and then displaying an alert message. But it could take a while for 3700 records.
But the formatting of an index number prefixed with 3 characters would be easily achievable with a Number field with the Auto-increment function enabled and a Calculation field that joins them together using the FORMAT() function.
For example:
PREFIX + FORMAT(Number; "000")The FORMAT() function will take the Number field and format it so that it contains prefixed 0’s.
Attachments:
You must be logged in to view attached files.November 4, 2024 at 12:17 AM #51257
Daniel LeuParticipantI’m not certain that Brendan’s approach works as expected. The auto-increment number would be independent of the prefix. So you might end with AST001, LLK002, AST003, …. But AST002 would not exist.
I would use a form script that provides you with the next valid entry. Create a saved search for your prefix’s, and then have a form script analyzes this subset of records and recommends you the next valid number to be used. I do this with barcodes that I assign to my artwork.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks -
AuthorPosts
You must be logged in to reply to this topic.