John M
12-25-2001, 06:19 PM
Scenario:
Book type is bounded field with choice of "Hire" or "Sell". I can set up an option group but it would mean that I will store 1 or 2 respectively in the underlying table. Can option group be programmed to store other values besides numbers.
David R
12-26-2001, 07:47 AM
Try this topic and answer from Pat Hartman: http://www.access-programmers.co.uk/ubb/Forum4/HTML/002383.html
HTH,
David R, search engine guru, Access neophyte.
Jack Cowley
12-26-2001, 07:48 AM
From Access Help:
"The OptionValue or Value property is set to a number because the value of an option group can only be a number, not text."
John M
12-26-2001, 10:22 AM
Hi David R,
This might sound dumb but I can't get it to work. Here is my situation that I tried.
I have "table1" with "field1" of text type. On the form (bounded to table1) I have created an option group "frame1" with labels "buy" and "sell". In the frame control I set control source =Choose([field1], "buy", "sell"). The message I get is that the control cannot be edited. Please tell me what I doing wrong here. Your help is really really appreciated.
Thanks
Pat Hartman
12-26-2001, 01:23 PM
You cannot use =Choose(...) as the controlsource for an option group. The controlsource needs to be numeric.
Start again.
1. Define YourField as Integer in the table.
2. Delete the option group and re-add it using the wizard. You want the option group to be bound to YourField. When the value of YourField is 1, the first option will show as selected, when it is 2, the second option will show as selected. If YourField is null, neither option will be selected.
The form will show an option group and store either a 1 or a 2 in YourField. If there is another place where you want to display this field as text rather than a number (such as a report), then use the Choose() function to translate the numeric value to text.
Calculated fields are not updateable. So, using =Choose(....) as a controlsource makes a field "calculated" and therefore not "bound". Only bound fields are updateable.
If you don't want to use an option group at all, you can store whatever you want in your table.
boblarson
12-26-2001, 06:40 PM
Or, if you want to enter "Hire" when Option 1 is selected and "Sell" when Option 2 is selected do this:
Place a text box with Visible set to NO on your form. Bind that text box to the field where you want the text "Hire" or "sell" to show up.
In the ON CLICK of the option box place this code (optMyOptions is the name of your option group, txtMyHiddenTextBox is whatever name you give your hidden text box):
Select Case optMyOptions
Case 1
txtMyHiddenTextBox.Value = "Hire"
Case 2
txtMyHiddenTextBox.Value = "Sell"
End Select
I use that method quite frequently.
BL
hth
[This message has been edited by boblarson (edited 12-26-2001).]
John M
12-27-2001, 08:48 AM
Pat,
I got you. What you are saying is that in the table level it is still an integer but you use the Choose() function to translate the full key.
Thanks
lame_designer
02-03-2006, 01:05 AM
Very helpful post, thank you.. I will use this alot..
Although in my case this option doesn't work.. I have an option group with 2 options: Dutch and English. When I select Dutch I should see a dutch letter to the customer in my text box, when I select English it should display the english translation.. I should also be able to store the letters in the table my form is bound to..
I searched the forum to find an answer but couldn't find any.. My apologies if this question has been asked before
Pat Hartman
02-03-2006, 09:14 AM
I don't understand what about it doesn't work. The user chooses option1 and you open the Dutch letter. The user chooses option2 and you open the English letter.