![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, In a single file (table) I keep records of documents and I need to assign unique Serial, but depending on a Year (date). Let' assume I have 15 records for 2006 and 10 records for 2007. What I want is when I enter a new record for i.e. 12/31/2006, FMP to give 16 as serial number and if I enter a record for 1/1/2007 to give 11 as serial and so on. FMP 8.5 - Mac OS 10.4.9 Any help for this will be appreciated. Nick Trimmis |
#3
| |||
| |||
|
|
Hi all, In a single file (table) I keep records of documents and I need to assign unique Serial, but depending on a Year (date). Let' assume I have 15 records for 2006 and 10 records for 2007. What I want is when I enter a new record for i.e. 12/31/2006, FMP to give 16 as serial number and if I enter a record for 1/1/2007 to give 11 as serial and so on. FMP 8.5 - Mac OS 10.4.9 Any help for this will be appreciated. |
#4
| |||
| |||
|
|
In article <C2623F5A.122AE%ntrimmis (AT) hotmail (DOT) com>, Nick Trimmis ntrimmis (AT) hotmail (DOT) com> wrote: Hi all, In a single file (table) I keep records of documents and I need to assign unique Serial, but depending on a Year (date). Let' assume I have 15 records for 2006 and 10 records for 2007. What I want is when I enter a new record for i.e. 12/31/2006, FMP to give 16 as serial number and if I enter a record for 1/1/2007 to give 11 as serial and so on. FMP 8.5 - Mac OS 10.4.9 Any help for this will be appreciated. First you need to know the year for each record by a Calculation field using the Year function. eg. RecordYear Calculation, Number Result = Year(DateField) Now you can use this field for defining a Relationship to group together all the records of the same year. eg. rel_SameYear Match records when RecordYear = SameTable::RecordYear Most people's first thought is to then use the Count function to know how many records for the year exist and add 1 to it ... BUT that's a mistake. If you later delete any record you will end up with two records using the same "serial number". ie. If you have records numbered 1, 2, 3, 4, and 5 You delete record 3 When you create a new record, the count is only 4 records so the new record becomes 5 giving a duplicate serial number Instead you need to use the Max function to work out what the maximum current "serial number" for the year is, and then add 1 to it. eg. SerialNumber Number, Auto-enter by Calculation: = If (IsEmpty(RecordYear), "", Max(rel_SameYear::SerialNumber) + 1) The If (IsEmpty(RecordYear), "" part is used to force FileMaker NOT to calculate the "serial number" until the record has a date entered and the Year calculated. If there are not any existing records for the year, then the Max TKn Texas and Helpful Harry, |
![]() |
| Thread Tools | |
| Display Modes | |
| |