Michael:
On the one hand there's no point reinventing the wheel, though on the other
hand you'd learn more about database design as you go along if you start from
scratch. It really depends how far you want to modify Northwind. You might
find that you'll modify something quite small and then spend a long time
pinning down what you need to do to something else to accommodate your
original modification.
I would not create a column for your structured CustomerID. It would
introduce redundancy. As you'll have Firstname and LastName columns already
you can get the first four characters from those. I'd suggest you include a
DateStamp column in the table of date/time data type and set its DefaultValue
property to Date(). Then for the sequential number use a column of long
integer number data type, CustNumber say, and increment it in the Customers
form's BeforeInsert event procedure with:
Me.CustNumber = Nz(DMax("CustNumber","Customers"),0) + 1
Don't be tempted to use an autonumber for CustNumber; an autonumber is
designed to guarantee uniqueness not sequence and can't be relied on for the
latter.
So you only have to enter the customer names, the rest is done automatically
and you don't need to show the DateStamp or CustNumber fields anywhere in the
application. In forms, reports etc you can show the structured CustomerID in
an unbound control with a ControlSource of:
= UCase(Left(LastName,2) & Left(FirstName,2)) & Format(DateStamp,"mmyy") &
Format(CustNumber,"00000")
As the CustNumber values will be unique make this the Customers table's
primary key and use an identical column in related tables, e.g. Orders, as a
foreign key, indexing them non-uniquely in those tables.
One final word of warning. Don't under any circumstances use the 'Lookup
Wizard' for the data type of foreign key columns like CustNumber. Just use a
number data type and set its Field Size property to Long Integer (which is
the default for numbers as it happens). You can 'look up' the text values in
combo boxes on forms; there is no point doing it in a table design where it
causes a number of problems. See the following for the gory details:
http://www.mvps.org/access/lookupfields.htm
Ken Sheridan
Stafford, England