Solved

Option box in Access

Posted on 2013-12-12
6
501 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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 36

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SetProperty Foreground Colour 5 15
90 days before current date 12 32
Number of records returned on a form 5 25
tab to another sub form 4 15
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

831 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