Solved

Option box in Access

Posted on 2013-12-12
6
473 Views
Last Modified: 2013-12-16
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?
0
Comment
Question by:cansevin
6 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 39714590
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
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39714604
Another option would be to use a combo box rather than an option group.
0
 

Author Comment

by:cansevin
ID: 39714617
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?
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39714740
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"
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 39716911
Option groups are best used for very small sets of options that are not likely to change since changing them requires changes to forms and possibly reports also.

Combos provide for infinite (OK, maybe not infinite) lists of options and do not need to change when you add new ones.

Listboxes are the middle ground.  They also provide "infinite" lists but since you size them to show a specific number, they may need to be changed if you add additional items to the list but as long as you enable the scroll bars, you don't really have to modify the form, the user can just scroll to his choice.

Option groups are limited to storing numeric values and I suggest you stick with that because in addition to the code already suggested, you would need code in the form's current event to take the text values from the table and convert them to numeric so the option group shows the current value.

In any case, whenever you have a list of more than a few items or if the list is subject to change, it should be maintained as a table.  Given that, for reporting, you would use a query that joins to the lookup table and selects the text value.  That way your report can show the descriptive value rather than the numeric ID value.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39718706
Draw a sketch showing the look required.
Give an example of what to expect when clicking an option.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now