It is pretty straight forward. I step through the script below and the 'Set next serial value...'
at the bottom does execute. But, when I add a new Member record, I get the next serial
incremented by 1 instead of 10. Waz up with that?
You should start the debugging process by setting variables and using the Data Viewer to check their value (or a custom dialog if you don't have FMPA).
Go to Record [ First ]
Set Variable [ $this.id ; Members::KP_MemberID ]
Set Variable [ $increment.value ; 10 ]
Set Variable [ $next.serial ; $this.id + $increment ]
Set Next Serial Value [ Members::KP_MemberID ; $next.serial ]
Debug shows that it 'should' work....
But, my import (sample) is but 2 records. When I hit 'add new record' it shows a PK of 3... Not 12.
How can that be? I must be missing something really fundamental.... grrr
Thanks for the reply
Do you do an error trap right after the "set next serial value"? If so, does come back with an error?
Are you running the script with full access privileges and if you go to Define fields after the script runs, what is the next value? Do you by any chance have an auto-entry option for the PK that might be causing the problem.
I stepped through the script with 'Pause On Error' checked and did not get an error ....except I noticed that further up in the script and PRIOR to executing this part of the script, I go to various layouts and execute a 'Delete all records' command which, oddly enough, generates a Error 3 : Command Unavailable. But, the command seems to execute.
Define fields shows the next record is 12
Your PK has an auto-enter. This will override the next value.
The problem was NOT in the script that defined the Set Next Serial Value. That part is working.
The problem was in my 'Add New Record Script'. For reasons not now known to me, (I've been working on this app for almost 2 years) I put in a Set Next Serial Value = PK +1.
I commented it out and all works as expected....
As usual, it is somehow my fault. Thanks to all for directing me toward the solution.
Retrieving data ...