Specify values for option buttons bound to lookup column

M

McGeeky

Hi. I have a basic question here but I am stuck on it.

I have a lookup column with two values: High and Low. I have added a option
button group and two option buttons to my form. The group is bound to the
database column. However, when I select one of the option buttons either a 1
or a 2 is set in the database column. How do I tell the option buttons to
set High or Low in the database column instead?

Thanks!
 
A

Allen Browne

You can't. An option group can store only numbers.

Use a combo box instead.
 
M

McGeeky

Ah, that's a pain. Is it possible if some VB code was used to sit between
the database column and the option group?

Thanks Allen!
 
A

Allen Browne

Perhaps you could create a little table with 2 fields, like this:
PriorityID Number
Priority Text
Then enter 2 records:
1 Low
2 High

Now create a query that uses your original one and this little one, joined
on the PriorityID field. You can output the text field for your report or
whatever.
 
M

McGeeky

Hi Allen. That's a good idea thanks; I may switch to that approach or use
your original combo box idea as they both require no custom code.

However! Is it possible to write completely bespoke VB code such that an
option group can be mapped to database column lookup values? E.g. I trap an
"update" event on the form where I can inspecte the option group values and
manually write the High/Low value to the database?

Thanks.
 
A

Allen Browne

You could have an unbound option group.

In its AfterUpdate event, populate the (hidden) field with the appropriate
text value.

Also use the form's Current event to set the value of the option group (each
time you change record.)

And use the form's Undo event to reset the option group to the OldValue of
the hidden field.

I really can't imagine that's worth the trouble when a simple lookup table
is actually the right (normalized) solution.
 
M

McGeeky

Hi Allen. Once again, thanks for your guidance.
I really can't imagine that's worth the trouble when a simple lookup table

You are right, its a lot of work & more moving parts to go wrong. We will
proceed with the lookup table option.

Cheers.

McGeeky
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top