Solved

Option Buttons - None numeric value?

Posted on 2011-02-14
20
808 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
  • 7
  • 5
  • 4
  • +2
20 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
to capture a letter "A", set the value of the option button to 65 and use

chr(optiongroup.value)
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
<<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
Comment Utility
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
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
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
Comment Utility
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 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
Or use choose:

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

JimD.
0
 

Author Comment

by:smods
Comment Utility
Cheers capricorn1

Where do I enter these?
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 167 total points
Comment Utility
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
Comment Utility
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 119

Expert Comment

by:Rey Obrero
Comment Utility
you have to unbound the Option Group and save records by using vba codes
0
IT, Stop Being Called Into Every Meeting

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!

 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
<<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
Comment Utility
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 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 166 total points
Comment Utility
<<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
Comment Utility
Cheers Jim,

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

Expert Comment

by:Rey Obrero
Comment Utility
<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
Comment Utility
Here's a sample of what the others are saying

Cheers
JC
ee26819486.mdb
0
 

Author Comment

by:smods
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks all.
0

Featured Post

IT, Stop Being Called Into Every Meeting

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

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…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
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 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…

772 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

12 Experts available now in Live!

Get 1:1 Help Now