Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 820
  • Last Modified:

Option Buttons - None numeric value?

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
smods
Asked:
smods
  • 7
  • 5
  • 4
  • +2
3 Solutions
 
Rey Obrero (Capricorn1)Commented:
to capture a letter "A", set the value of the option button to 65 and use

chr(optiongroup.value)
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<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
 
smodsAuthor Commented:
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
Rey Obrero (Capricorn1)Commented:
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
 
MINDSUPERBCommented:
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
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Or use choose:

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

JimD.
0
 
smodsAuthor Commented:
Cheers capricorn1

Where do I enter these?
0
 
Rey Obrero (Capricorn1)Commented:
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
 
smodsAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
you have to unbound the Option Group and save records by using vba codes
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<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
 
smodsAuthor Commented:
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
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<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
 
smodsAuthor Commented:
Cheers Jim,

I used capricorns code but it's not capturing the values in the table!
0
 
Rey Obrero (Capricorn1)Commented:
<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
 
JVWCCommented:
Here's a sample of what the others are saying

Cheers
JC
ee26819486.mdb
0
 
smodsAuthor Commented:
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
 
JVWCCommented:
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
 
JVWCCommented:
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
 
smodsAuthor Commented:
Thanks all.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 7
  • 5
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now