Solved

Option box in Access

Posted on 2013-12-12
6
493 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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 35

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

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