I have a customer who wants their service comments to be ordered by date when they view them. To do this I have added a new key. However now when you try and insert a new comment in the form when this key is in use (The key is set to be the default for that form in the properties) it gives an autosplitkey error. I understand why this is happening (I think) - Because there is a line no. in the key and the line no’s are out of order it can’t insert a new entry with the correct line no. Does anyone have any suggestions on how to get around this issue? I have tried SETCURRENTKEY in the OnInsertRecord trigger on the form with no success… Cheers Stoo
Hi, for Autosplit functionality the last filed in Key must be numeric type! Add Line No. field at the end of your actual Key. This should solve your problem. By, Stanko
quote:
Originally posted by stane
Hi, for Autosplit functionality the last filed in Key must be numeric type! Add Line No. field at the end of your actual Key. This should solve your problem.
I’m sorry, but this won’t work. Using the AutoSplitKey facility won’t make sense, when there’s dates involved (unless it’s the same date). Moreover AutoSplit can only be used on the primary key. I’m afraid you’ll have to look at alternatives.
Quite right. I’d already tried adding the Line no. as the last field of the key unfortunately as it was sorted in date order you could get instances where the first line was line 30000 and the second 20000 if you then try and add in a new line it can’t as it tries to create with Line No. 30000 (Which already exists). Any one have any great ideas[?]
Hi Stuart, We had the same issue here. If your customer wants a different order than the order specified by the user (using the autosplitkey functionnality), the first thing to do is to make sure they understand the autosplitkey functionnality and how it allows the user to specify the order they want. If they really want to stop using AutoSplit and sort by date, here are some options:
- Build another form or view non editable to display the records in the orders they want (display only).
- Disable the autosplit key functionnality and put some code to generate another Line No. (ex: in the OnInsert Trigger, FIND the biggest Line No. within the filters and add 10000). In this case, the Line No. value is not important, because the users don’t need to change the order by their action.
You could also change the primary key of the table, but I wouldn’t recommend that. First of all, it’s a bigger job, and when you change a primary key, you have to consider all the side effects on all other objects using this table.