February 10, 200421 yr Hi, I want to configure a number field A to be set automatically to: value of field A in last record + 1 How can I do that? Tx for helping! Alain
February 10, 200421 yr Max(SelfJoin:A)+1 where SelfJoin is a Self relationship on a constant number of 1 (set to autoenter) or a calculation (still of 1).
February 11, 200421 yr This assumes that the value in the last record is also the maximum value for the field. Will that always be true?
February 11, 200421 yr True ! I'm so use with this using with serials...where (in my solutions), they never get deleted. Then you could use an unstored calc with c_latestSerial =Max(SelfJoin::serial), and relationship from that calc to the serial field, call it RelByMaxSerial So that the max A value would be (RelByMaxSerial::A)+1
February 11, 200421 yr I have used this Max(Selfjoin::Serial)+1 method on a couple of projects and have now gone back and removed it because we noticed that after getting a bunch of records into the database, things were slowing down dramatically. Mind you, there were some other things happening too that were partly responsible. Also, if this is a multi-user application, it's guaranteed that you will eventually get unwanted duplicates as two users try to create a new record at the same time.
February 11, 200421 yr From what I read of the question, it's not clear what they want; but it doesn't sound like a Max of the field (which is as you say, slow as toast). It sounded like they wanted to add 1 to the value in a field of the "last" record. Assuming that "last" means the previous record in creation order, then the simplest method is to just go back one record and get it, then go forward one. If however you need to do this with a scripted loop in a large found set, there is a more advanced method of looking up the serial ID of the "previous" record, using a self-relationship. Ugo and I recently did this for LaRetta. The Subject was "Modify Line by Previous." Example file: http://www.fmforums.com/threads/download.php?Number=92032
Create an account or sign in to comment