It is not hard if you have the right to tools.
Are you using SQL to capture this data? SQL can automatically create your IDs.This is always best since they are created upon save and therefore you have no worry of duplication.
Qdabra Database Accelerator Suite Version 2.1 - Developer
To create it within your form is problematic, since whatever method you use to create a unique number can be happening in another user's form at the same time. There are ways to lower the chance of duplication but there are always going to be uniqueness issues.