Counter Field in Subform

Counter Field in Subform

Hi - new user
 
I like to use a counterfield as a unique ID for related Forms.
 
I have placed script to create the counterfield value - it works fine in the forms .
 
However it does not work when the form is placed as a subform. eg it returns only the previously succesful data - not the current field I am trying to link to:
 
eg
 
Form . Clinical      Counter Field Clinical ID  
Form . Clinical Detail    Counter Field . Clinical Detail ID
 
as above they work fine and auto update for the next "new" field  AS seperate forms.
 
but if I place the form Clinical Detail as a subform the Counter Field  Clinical Detail ID does not return the current "new" Counter Field . Clinical ID
 
is there workable solution around this??
 
Thanks
Garry