Hi -- how are you currently populating the cell that works correctly (on open)? Are you using a default value? Did you know that on a repeating table you can set defaults that are just used when a user inserts a row into a repeating table?
You might want to consider setting the first contract number using an open rule. Then, when users insert new rules, you could use the first contract number as the 'seed' value for the next ones....Of course, depending on how many people are using this form at any one time, these methods have risks -- what if one person has started a form, and hasn't submitted data, and someone else starts a new form at the same time? You could end up with conflicts. In case it might help you, here is a blog post I wrote on a method for generating unique IDs using stored procedures....