Solved

Option Buttons - None numeric value?

Posted on 2011-02-14
20
809 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
ID: 34887557
to capture a letter "A", set the value of the option button to 65 and use

chr(optiongroup.value)
0
 
LVL 57
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
 
LVL 119

Expert Comment

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

Assisted Solution

by:Rey Obrero
Rey Obrero 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 119

Expert Comment

by:Rey Obrero
ID: 34888456
you have to unbound the Option Group and save records by using vba codes
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 57
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 57

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 119

Expert Comment

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

943 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

10 Experts available now in Live!

Get 1:1 Help Now