Greg, It is not clear if the code works on a single record or over a group of records.
If it is a new record in the Main form there won't be any entries in the subform so Diff1 will be zero.
After creating the new record in the mainform you could pass focus to the subform and then to a field on the sub form so that your code is initiated when the subform is exited.