How to code auto numbering on certain criteria?

How to code auto numbering on certain criteria?

Could someone help, please?
I'd like to have an auto number field based on certain criteria.

I want to count a delivery note document. The delivery may happen in multiple actions. 
If I edit the record in the same action several times it should not influence counting.
For example:
In delivery1 action I open the report for editing and update two qty fields. It means +1 in counting. Later I open the record for another editing, but this is still delivery1 action, so there is no counting etc.
Next time I open the record for editing delivery2, then it means +1 in counting again.

The relevant fields are ordinary form fields and not subform fields: 
Field names: delivery action, serial number
Do I need number field, or single li field is OK?
Of course I do not want to count only one FormA, but FormB, FormC etc.
Example:

Delivery action                              serial number
FormB action1                                          1
FormB action1                                          1
FormA action1                                          2
FormB action2                                         3
FormC action1                                          4                  etc

Thanks, if anyone can help!
Best wishes