Hello all, I have a table with a field [SortOrder] as double. I use it to sort my form lists. Let's say I want to insert a record between [SortOrder] = 5 and [SortOrder] = 6. I currently just make the new [SortOrder] = 5.5 and it works fine but what if I want to insert another record between 5 and 5.5? With my current code, it would try to create another 5.5 and cause an error because I did not allow duplicates.
Assuming I set focus on the record I want to insert a new record immediately after, my idea is to find the next [SortOrder] number after the current one, subtract by the current number, divide by 2, then add that to the current number to get the new number exactly half way in between. This will ensure I never duplicate the [SortOrder] number. What I can't figure out is the first step, finding the next number.
I thought maybe a MIN([SortOrder]) which is greater than current [SortOrder]? Any suggestions? Please include coding, thank you.
Assuming I set focus on the record I want to insert a new record immediately after, my idea is to find the next [SortOrder] number after the current one, subtract by the current number, divide by 2, then add that to the current number to get the new number exactly half way in between. This will ensure I never duplicate the [SortOrder] number. What I can't figure out is the first step, finding the next number.
I thought maybe a MIN([SortOrder]) which is greater than current [SortOrder]? Any suggestions? Please include coding, thank you.