Something else that seems to be popular is to try and create and primary key field that uses the date in conjunction with an autonumber, for example 010120010001 might be the first record that was created on 1 Jan 2001, whilst 050220010015 would be the fifteenth record created on 5 Feb 2001. This is a very bad idea - the idea of relational databases is to store one piece of information in each field. If you wanted to do something like this, you would need to modify the code above slightly, and add a date field to the table:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!UniqueFieldName = Nz(DMax("[UniqueFieldName]", "[tblUnique]", "[DateField]=Date()"), 0) + 1
Me!DateField = Date
End Sub
You can then create a primary key for the table that is based on both the DateField and UniqueFieldName by selecting them both in the design view of the table by using the Control key and then clicking on the Primary Key symbol. You will then have a number that increments each day, and resets itself the next day.