Solved

Option Buttons - None numeric value?

Posted on 2011-02-14
20
816 Views
Last Modified: 2012-06-27
Hi there,

I have a set of option buttons on my form which I want to capture certain details.  Having used infopath before which captures whatever value you like, I was surprised to see access will only let me capture a numeric value.  Is there any way around this?

Regards

Chris
0
Comment
Question by:smods
[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
  • 7
  • 5
  • 4
  • +2
20 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34887557
to capture a letter "A", set the value of the option button to 65 and use

chr(optiongroup.value)
0
 
LVL 58
ID: 34887559
<<Is there any way around this?>>

  Not sure I understand; based on the option selected, you can store anything based on that value by using the groups AfterUpdate event.

JimD.
0
 

Author Comment

by:smods
ID: 34887595
Sorry for not being clear.  I wish to capture specific reasons such as "Incorrect process followed" etc but access only seems to allow me to store a numeric value.

Regards

Chris
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34887633
you can assign those String values to the values in an option group

dim strText as string
select case optiongroup

 case 1:strText="Incorrect process followed"
     

 case 2:strText="Correct process followed"


etc..

end select
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 34887649
Chris,

How about make your option group unbound. Then, use VBA as a way around to capture the text value of your field.

E.g.

If Me.fraOption = 1 Then
Me.YourField="A"
Else
Me.YourField="B"
End If

Sincerely,
Ed
0
 
LVL 58
ID: 34887674
Or use choose:

   =Choose(Me.<groupcontrolname>, "Text option 1", "Text option 2", "Text option 3")

JimD.
0
 

Author Comment

by:smods
ID: 34887998
Cheers capricorn1

Where do I enter these?
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 167 total points
ID: 34888089
you can use the afterupdate event of the option group.

private sub optiongroup-afterupdate
dim strText as string
select case optiongroup

 case 1:strText="Incorrect process followed"
     

 case 2:strText="Correct process followed"


etc..

end select
0
 

Author Comment

by:smods
ID: 34888430
Thanks,

Is this supposed to automatically update the values in the table?  They're still showing as 1, 2, 3 etc in the table.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34888456
you have to unbound the Option Group and save records by using vba codes
0
 
LVL 58
ID: 34888480
<<Is this supposed to automatically update the values in the table?  They're still showing as 1, 2, 3 etc in the table. >>

  That would be correct.  If you want the strings stored, you'd use and unbound option group, then set a bound, hidden text control with the string you want stored in the afterupdate event.

  However, that is not the norm.  Usually you store only the value.

JimD.
0
 

Author Comment

by:smods
ID: 34888496
Sorry I don't understand.

The option group is now unbound and I entered the code you have provided.  What code do I need to enter in order to get the data to save?
0
 
LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 166 total points
ID: 34889814
<<What code do I need to enter in order to get the data to save?>>

  If the form is bound (has a controlsource), then the user moving off the record will save it unless an un-do is performed.  You need do nothing else other then having the code in the option groups after update event.  That code places the text either in a bound text control or directly into a field depending on what you went with from the above.

Jim.
0
 

Author Comment

by:smods
ID: 34892762
Cheers Jim,

I used capricorns code but it's not capturing the values in the table!
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34893193
<I used capricorns code but it's not capturing the values in the table!>

does not mean anything, if you will not post the codes you used...
0
 
LVL 6

Accepted Solution

by:
JVWC earned 167 total points
ID: 34894471
Here's a sample of what the others are saying

Cheers
JC
ee26819486.mdb
0
 

Author Comment

by:smods
ID: 34896028
Cheers for that JVWC.

That's working now! I can see where I had gone wrong.  Once I add a record now on my form it is capturing the text, however the last option button selected still remains automatically selected?
0
 
LVL 6

Expert Comment

by:JVWC
ID: 34904455
In my example I showed both the bound field and an unbound field that is set by the afterupdate code.
The option box  will always refflect the value in the bound field.

If you only need the text then remove the contol source from the option box in form design view.

Cheers
JC
0
 
LVL 6

Expert Comment

by:JVWC
ID: 34904477
smods
Please note JDettmans comment above 34888480.

It is far more efficient to store only the the value and the process that into text as you require..

Cheers
JC
0
 

Author Closing Comment

by:smods
ID: 34915370
Thanks all.
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

627 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