Hi, I have a trigger in a table that runs On Update to copy and insert new records into the same table. This happens when a user selects multiple records in a tabular datapage and uses Bulk Edits to check a field 'CopyIt'. If a record's 'CopyIt' value = true then it goes through the trigger.
This works fine for copying multiple records at the same time into the same table. The issue is I have a field (ItemNum_Integer) in that table that needs to be sequentially ordered for each new record (sort of like an autonumber record but not set to that because sometimes the values start over for subrecordsets and have to be changed).
So the first new, copied record's ItemNum_Integer value would be the Max of the existing ItemNum_Integer in that table (joined by a common ID number so it uses a sub-recordset) + 1. This works but ONLY for the first new, copied record. Every record thereafter uses the same value. So if I copy 5 records the first record will have the correct Max ItemNum_Integer + 1 value but then each record after it will use the same number. For example, if the first new/copied record has a Max ItemNum_Integer + 1 value of 106 then each of the five new records repeats 106 for their ItemNum_Integer value when they need to be 106, 107, 108, 109, 110 respectively.
It seems like somehow the Max ItemNum_Integer + 1 isn't firing sequentially. Does anyone know how to do this?
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
DesiLogi
Hi, I have a trigger in a table that runs On Update to copy and insert new records into the same table. This happens when a user selects multiple records in a tabular datapage and uses Bulk Edits to check a field 'CopyIt'. If a record's 'CopyIt' value = true then it goes through the trigger.
This works fine for copying multiple records at the same time into the same table. The issue is I have a field (ItemNum_Integer) in that table that needs to be sequentially ordered for each new record (sort of like an autonumber record but not set to that because sometimes the values start over for subrecordsets and have to be changed).
So the first new, copied record's ItemNum_Integer value would be the Max of the existing ItemNum_Integer in that table (joined by a common ID number so it uses a sub-recordset) + 1. This works but ONLY for the first new, copied record. Every record thereafter uses the same value. So if I copy 5 records the first record will have the correct Max ItemNum_Integer + 1 value but then each record after it will use the same number. For example, if the first new/copied record has a Max ItemNum_Integer + 1 value of 106 then each of the five new records repeats 106 for their ItemNum_Integer value when they need to be 106, 107, 108, 109, 110 respectively.
It seems like somehow the Max ItemNum_Integer + 1 isn't firing sequentially. Does anyone know how to do this?
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.