Duplicates can happen this way if two users are creating records at the same time. The counter won't increment until the record is committed. So, one user (well, actually I think this could be the same user if creating related records!) creates a record, but doesn't commit it for 8 seconds because they're editing it. Another user creates a record in that time, and the calc will return a duplicate.

If you're creating related records, it gets even trickier, since one user can create multiple new child records before a commit. I suppose one user could create multiple parents if using multiple windows too.

You can force a commit on creation (by using a custom menu for the New Record command). You could also use FileMaker's auto-enter serial number to increment. You'll need to reset that number every month with a scripted process. Ideally a server-side script, though possibly an "on open" script. Or a script tied to the new record command that checks to see if the number has been reset this month in a another table.

As Damian said, you could also use field validation, along with a New Record scripted process. You'd capture the validation error and increment until you found a unique number.

New Record and Commit should work 99.9% of the time. It'd be tough for two users to make the same record at the exact same time. But if you want to be safe...Instead of Delete[] how about just setting the key field?

New Record/Request

Loop

Exit Loop If [ $pass ]

Commit[]

If [ Get ( lastError ) ]

Pause [ 1 ]

Set Field [ table::serialNumber ; your.calc ]

Else

Set Variable[ $pass ; 1 ]

End If

End Loop

That way you're not mucking about with multiple new records and deletes, just updating the field.