Zippy Aus Posted December 13, 2007 Posted December 13, 2007 Hi all I am stumped. I can do this with a script which sets the fields, but I would like it to be dynamic if possible. I have a database of documents, there are main documents (eg. 1) and sub-documents (eg. 1.1). When I sort these documents into date order, I would like the numbers to reflect the order with sub-numbers. I am trying to find a calculation that will take the value of the previous field and add 1 if it is a maindoc or not if it is a sub doc. My script basically loops through setting a global field to the documentID and then if the document is a main document it adds 1 to the global else it sets it to the global. Can this be done with a calculation? apendnth maybe? Any help would be greatly appreciated. Zippy
dreamingmind Posted December 13, 2007 Posted December 13, 2007 Zippy, We meet again, but not over cups steaming php this time! Here's a thought: if you build a sorted relationship so each record can see the record prior to it in your found set, this would give a calculation a basis for determining what value to output. It's been a little while since I had to dig deep into what could and could not be calculated. There may be a problem with calculating from related data like that... But maybe that will spark some ideas. Regards, Don
Zippy Aus Posted December 13, 2007 Author Posted December 13, 2007 Solved (I think). I have had to use two fields. The first calculates the Main Number and then second appends the sub-number. I have called the field AutoNumber and it references itself. Case ( Get ( RecordNumber ) = 1 ; 1; IsEmpty (SubNumber) ; GetNthRecord ( AutoNumber ; Get ( RecordNumber ) - 1 ) + 1 ; GetNthRecord ( AutoNumber ; Get ( RecordNumber ) -1 ) ) I then have a field called CalcNumber which is AutoNumber & If ( IsEmpty (SubNumber) ; "" ; "." & SubNumber) It all seems to work ok ... now to put it into practice and see how it performs ZP
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now