Table fields:- Setting default values to be based on other field values

  • Thread starter Thread starter Rob W
  • Start date Start date
R

Rob W

Greetings,

Is it possible to define at a table design level that a default vaule of a
field is based on other fields?

For example

Field "Name" = Field "FirstName" + "SecondName"

Thanks
Rob
 
It's not possible and, in fact, wanting to do something like that is usually
an indication that the table hasn't been properly normalized. In your
example, Name shouldn't exist in the table: it's redundant (since it's based
solely on values in other fields of the same row).
 
Thanks well Ive got a primary key that is needed to join tables and I didnt
want an autonumber (always warned against these), though I didnt want the
user to worry about typing something unique in, as to them the data is not
intended to be read by humans.

Easier to explain by showing my DB schema.

Maybe write some code to use the recordcount to create a field value?
 
I'd be curious to know why you were told to avoid autonumbers.

In any case, though, if you want a natural key, you can have up to ten
separate fields in a single index, so if your intent was to create a unique
index on First and Last Name (which, incidentally, probably isn't adequate),
all you'd have to do is include those fields in the primary key, not create
an artificial one.
 
Back
Top