I created the Gender Text Field as indicated in the Personnel Table. On the
Form I used a combobox and typed the values: M,F into it (vice looking the
values up in a Gender Table) and stored it in the gender field of the
Personnel table. Worked exactly as you stated, thank you so much.
I also tried creating a table: GenderID (Autonumber), Gender (Text) with the
values M, F, and linking this Gender Text field to the Gender Text field in
Personnel table. On the form, I input a combobox, looked the values up in
the Gender table, selected to store the value in the Personnel table Gender
text field with the validation rule IN ("M","F") and this did not work. The
field would not accept either the M,F choice of the combobox. The
relationships window would not allow me to use referential integrity or
cascade options when I did this.
Correct. It won't.
Your personnel table - with this second option - will contain, not a gender
letter, but a *long integer number* (the GenderID, a link to the numeric
autonumber value). The validation rule will fail because the "lookup field"
does NOT contain what it appears to contain. What *you* see is F or M; what
the table actually contains is 1 or 2. The numeric value 1 does not fit the
validtion rule since it is not equal to F nor is it equal to M.
Access really, really pushes you to give every table a Primary Key - which is
well and good; every table should have one. But it also pushes you to give
every table an Autonumber Primary Key - which is often useful but is
emphatically NOT required.
A Primary Key should meet three tests: it must be unique within its table; it
should be stable, so you don't have to deal with cascading updates if it
changes; and - preferably, but less critically - it should be short. In a
table of Genders, a single character text field meets all three criteria
admirably: it's unique (there won't be two records in the Gender table with
the same value); it's stable (F will always be Female, at least in the
ordinary use of a database; if you translate the database to German it might
become W but that's a one-time operation); and it's a quarter the size of a
Long Integer.
Keep it simple! For gender you don't NEED a Gender table. This is the kind of
data for which list-of-values is ideal.
Expanding to a bit more complex issue, consider a table of US States (and you
can throw in Canadian provinces too). Access may want to give you an
autonumber StateID, a state code ("ID", "MD", "TX") and a state name (Idaho,
Maryland, Texas). I'd argue that the autonumber is redundant and unnecessary.
Instead you can use a two-character text State field in your addresses, and
have the two-character code as the Primary Key of your States table. A combo
box on your form could store the two-letter ID while displaying the state
name, if you wish.
John W. Vinson [MVP]