B747 is correct on this. I have been able to swap my CO & HP FF #'s while travelling on a single ticket. Once the gate agents have closed the flight and reconciled the lifted tickets & boarding passes, the data is submitted to accounting & onepass for processing. Hence it is possible for you to receive credit on a segment-by-segment basis.
Sometimes the gate agents may look at you funny for trying to swap out your FF #'s, but if they try to tell you that they can't, they indeed are able to do so.