alain delcourt Posted February 10, 2004 Posted February 10, 2004 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
Ugo DI LUCA Posted February 10, 2004 Posted February 10, 2004 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).
Vaughan Posted February 11, 2004 Posted February 11, 2004 This assumes that the value in the last record is also the maximum value for the field. Will that always be true?
Ugo DI LUCA Posted February 11, 2004 Posted February 11, 2004 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
BobWeaver Posted February 11, 2004 Posted February 11, 2004 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.
Fenton Posted February 11, 2004 Posted February 11, 2004 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
Recommended Posts
This topic is 7661 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 accountSign in
Already have an account? Sign in here.
Sign In Now