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

x
?
Solved

Option Buttons - None numeric value?

Posted on 2011-02-14
20
Medium Priority
?
817 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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 668 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 664 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 668 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

730 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