The problem here is the DelayedInsert-property of the Sales Order Subform.
The line is not inserted at the time the user enters the Item No., and therefore also has no Line No. assigned yet.
If you want to force the insert, you can use the CurrForm.SAVERECORD command, prior to where you want to insert the record in the other table.
But you have to test thoroughly that this will NOT cause other problems, to insert the record earlier than expected.
As Alexander says, the problem is in the DelayedInsert property.
An other solution which I would advise is to add to table 37 a function which writes the record in your table. The function should exit doing nothing if any of the fields you need (such as “Line No.”, Type, “No.”, ecc…) is not filled in the variable Rec. Call the function in the OnInsert and OnModify triggers.
Please, if any of the replies to your post solved your problem, then please click on the “Verify solution” next to that post. This way we can see that your post is closed and you got the help you needed. If you found another solution to your problem, then please, out of courtisy to the members who helped you here, post the solution here.