We'll pick up where we left off last month with the
option group I built to help manage departments of a
summer camp.
To refresh your memory or if if you'd like to review the
details of how we got to this point see July 2008.
Here's where we left off, with a list of choices
presented to the user that allowed him or her to select
one of the choices:
The question now becomes "what can we do with
something like this?" As with many Access controls,
an option group can be bound (or associated with) a
field in a table so that the user's choice will populate
that particular field in the table. Let's go ahead and do
that.
As a first step, open your form in design view and then
select the option group; you'll find that when you select
the option group it will select all the objects within the
option group as you can see below.
Don't let this throw you-although all the objects in the
option group have been selected, if you go to the
properties view, you'll see that what you'll be acting on
is the properties of the option group, not its individual
components.
If you click on the data tab as I have above, you'll see
that one of the options you may change is the control
source - the control source is the binding (hooking in)
of a control on a form to a field in a table (or query). If
your form is bound to a table or query you may choose
to send the value selected in the option group to a
field within the table or query through the binding
process. It acts just as a text box or combo box does,
but rather than what the user enters as text, it's the
value of the item that is selected in the option box that
is bound to the control
This may be a tad counter-intuitive so let me explain. If
you remember from last month when we built the
option group, one of our decisions was what values
we would assign to each of the options within our
option group as in the picture below.
So if the user has selected Land Sports the value that
is stored is "1", Water Sports would be "2" and Arts &
Crafts a "3." If you already have a pre-defined value for
Land Sports of 256 for instance, then you could just as
easily declare that value of Land Sports to be 256,
either before or after having built the option group. In a
like manner if you are storing the word "Land Sports"
in your table you could substitute the value "Land
Sports" in the value column. You're really not limited
to what you use and the values declared, as long as
the field in which you're going to store your values is
defined to accept a value of that "type".
You might remember that last month when I built this,
I recommend using numbers as values because they
are faster and easier to manipulate. For my
purposes, when I design a table that will have many
rows, I'll almost exclusively use numbers wherever
practical and store the word equivalent in a separate
lookup table. This is a very powerful technique that
gives me great flexibility. I'll devote a future issue of
the Wizard to the how and why of expanded use of
lookup tables.