On Wed, 7 Oct 2009 13:45:01 -0700, JOM <(E-Mail Removed)> wrote:
>I want my auto number to be in the form of todays date and then the record
>number e.g., 10070901. If I enter a new record tomorrow, I want it to start
>with tomorrows date and start at 01. Is that possible?
No, not with an Autonumber; an autonumber has one purpose only - to provide a
meaningless unique key.
And it's a Bad Idea anyway. A date *IS DATA* and should be stored in a date
field, as data, not embedded in the Primary Key of your table. A field should
be "atomic" - containing only one piece of information; and a primary key
should emphatically not depend on the value of any other field in the table.
If you want to just display this composite, you can use a date field to store
the entry date (just set its DefaultValue property to =Date() ), and a Number
field which you can increment in your form's BeforeInsert event:
Private Sub Form_BeforeInsert(Cancel as Integer)
Me!SeqNo = NZ(DMax("[SeqNo]", "yourtablename", "[Datefield] = Date()")) + 1
End Sub
and concatenate them for display purposes. I'd use an Autonumber as the
primary key, but - if you insist - you could make this date field and the
SeqNo field a joint two-field primary key.
--
John W. Vinson [MVP]
|