You will need a database or a web service for this.
This topic has been brought up numerous times. You should be able to find more information on it by doing a search in Google Groups.

Signature
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com
Could someone help me with this?
What is the best way to assign a unique number to each new generated form?
The form will need to be published in four different locations and therefore
the number will start with a two letter code for the location plus an
incremental number. I would appreciate if someone could give me the code or
where to locate a sample file that does it, because Im not very good at
programming it.
Thank you
marc