View Full Version : Option Group Absurdity


Peter Paul
03-15-2001, 03:06 PM
Ok, let me try to explain:

I have a field, Offense_Status which needs to have either A - Attempted or C - Completed put into it. I would like to have option buttons for the choice. The book I am using says that I can have the option button enter A or C for true or false, but I cannot get that to work.

So, I decided on a simple workaround. On Got Focus on the first option button I input

If True Then Offense_Status = "A"
(and on the second button)
If True Then Offense_Status = "C"

This works. But, if someone goes back into the form to revise or to look at it, neither of the buttons is true.

So, on the Open event for the Form, I tried

Iif Offense_Status = "A", Option91 = True, Option93 = True

I tried a miriad of options here, but have not gotten it to work. I am assuming that there is a simple way to make this happen, and that I am just missing it.

As always, thank you in advance for your assistance,
Peter Paul

Pat Hartman
03-15-2001, 05:28 PM
The easiest thing to do is to use numeric values in the table for attempted and completed. Then in a report you can "decode" these values.

To actually store the letters rather than numbers you'll need to base your test on the option group and do it in the OnCurrent event and in the AfterUpdate event of the optonGroup.

Peter Paul
03-16-2001, 09:52 AM
Pat,
thanks for the help. So if I understand you, best to just store the data as is, 0 or -1 etc., and to translate it when I need it.

I just ordered a new Access book with VBA, so hopefully I won't need to trouble you too much more on these things. But, until then....

So where would I make the translation? Directly on the field in the report? In a query?

I can guess my way through the code:

Iif(Offense_Status = 1, "Attempted", "Completed")

or something as such?

Thanks again,
Peter

llkhoutx
03-16-2001, 10:56 AM
It seems to me that the field holding the offense status is not bound to the table which is the recordsource for your form.

Pat Hartman
03-16-2001, 04:20 PM
The Choose() function is an easy way to "decode" a small list of sequential values. Decoding in either the query or the control works.

Select Choose(YourFld, "val1", "val2", "val3") AS YourFldVal
From YourTable;

or as the control source for a control:
=Choose(YourFld, "val1", "val2", "val3")