Link to home
Start Free TrialLog in
Avatar of cansevin
cansevin

asked on

Option box in Access

I prob sounds stupid for this questions... but I can't figure it out.

I want an option box (with option buttons) that will store text I want it to. The "Option Wizard" only lets me save numeric values for the choices.

What am I doing wrong?
Avatar of omgang
omgang
Flag of United States of America image

Each Option button in the Option Group (Option Box) has a numeric data 'Value' associated with it.  In the After Update event for the Option Group you'd have code like

Private Sub grpMyOptionGroup_AfterUpdate()

    Select Case Me.grpMyOptionGroup
        Case 1    'this is the value assigned to the first Option Button
            strValue = "This is the String value I want to store"

        Case 2    'this is the value assigned to the second Option Button
            strValue = "This is the other string value I want to store"

    End Select

        'code here to save the select string value to the data table


End Sub


OM Gang
Another option would be to use a combo box rather than an option group.
Avatar of cansevin
cansevin

ASKER

Is there a way to make the combo box to have options to click? Or does it always have to be the drop down text?
a combo box is always dropdown, but you can define the size of a listbox and display as many "options" as you want in the list.  You can furthermore hide columns, so if you wanted to display State Names, but wanted to store state abbreviations, you could use a SQL query for the rowsource of the list:

SELECT StateCode, StateName FROM tblStates ORDER BY StateName

and then set the listbox properties:

BoundColumn: 1
ColumnCount:2
Column Widths: 0, 1.5

Then you would size the list vertically and horizontally at appropriate.  If you have a short list of options, you could set the listboxes RowSourceType to "Value List" and then in the RowSource, you would simply type:

RowSource: "Option 1"; "Option 2"; "Option 3"
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Draw a sketch showing the look required.
Give an example of what to expect when clicking an option.