Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Option box in Access

Posted on 2013-12-12
6
Medium Priority
?
519 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 48

Expert Comment

by:Dale Fye
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 48

Expert Comment

by:Dale Fye
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 39

Accepted Solution

by:
PatHartman earned 2000 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 31

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

722 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