Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

option value

Status
Not open for further replies.

mattsuppok

Instructor
Jan 28, 2003
14
US
on an option radio button, that is part of an option group, is there a way to set the value to any text that you wish, so that that value can be stored in the table. It seems to not let you select anything but numeric values.

Thanks in advance.
 
the value or the label? - if label, make it =iif(option = #, "text", "nottext?")

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Here is a work-around which may help.

-- Make your option group unbound. In my example the option group is called Frame1
-- Create a text box, bound to your table field. In my example, this is txtBound
-- Suppose the option group contains three radio buttons. These will return the option group values 1, 2 and 3 when clicked.
-- Add this code to the 'AfterUpdate' event of the option group:
Code:
Private Sub Frame1_AfterUpdate()
    Select Case Frame1.Value
    Case Is = 1
        txtBound = "Fred"
    Case Is = 2
        txtBound = "George"
    Case Is = 3
        txtBound = "Harry"
    End Select
End Sub
-- As you click an option button, you will see the bound text box fill with 'Fred', 'George' or 'Harry' as appropriate.
-- Substitute the actual text which you want to save, in the code.
-- After testing, make the bound text box invisible.

I hope that this helps.

Bob Stubbs (London, UK)
 
bob stubbs..

It works beautifully, but with one exception. When you reopen that form, those options buttons have no dots.
 
so on form open set the values back to their default.

look up optionvalue - there is a default to set that to.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
what I meant was that when you select a button, the afterupdate procedure runs, the text box is populated. When you close the form, then reopen to that record, the text box is still populated (good), but the option button is blank
 
To make the buttons reflect the value of the text field, when you display an existing record, you need a similar piece of VBA code. This time, the code runs from the form's On_Current event:
Code:
Private Sub Form_Current()

    Select Case txtBound
    Case Is = "Fred"
        Frame1.Value = 1
    Case Is = "George"
        Frame1.Value = 2
    Case Is = "Harry"
        Frame1.Value = 3
    End Select

End Sub
This will create the effect which you require - sorry I did not think of this in my original post!

Bob Stubbs (London, UK)
 
Has anyone looked at the [blue]Choose[/blue] Function?

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top