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

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

ACCESS VBA: Transfer value of radio button on form to table field

Hi,

I have an option group on a form that has 3 radio buttons, each with a different value.
I am trying to send the actual value of the radio buttons to a field in a table when the user selects a radio button.
The value could be an assigned value since they don't change.

What would be the code in VBA that could do that?

Any ideas? thanks for your help.

MC
0
MonteCristo33
Asked:
MonteCristo33
  • 2
  • 2
  • 2
1 Solution
 
jjafferrCommented:

Assuming the Group is called Group1, and each of these buttons have a value, assuming 1,2 and 3

"On Click" [Event Procedure] of Group1 have this code:

if Group1=1 then
 xyz="button one"
if Group1=2 then
 xyz="button two"
else
 xyz="button three"
end if

you should place the same code "On Load" of the Form too.

jaffer
0
 
jjafferrCommented:
xyz is your control on the Form, which is bound to the field in the Table,

sorry, for the "On Load" the code should be the other way around:


if xyz="button one" then
 Group1=1
if xyz="button two" then
 Group1=2
else
 Group1=3
end if
0
 
p912sCommented:
Is the form that the radio button is on linked to the table that will store the value? If it is then set the Control Source for the Frame/Option Grooup to the field that should store the value.

Hope that helps.

Scot


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MonteCristo33Author Commented:
Hi Scot,

the best solutions are always the simplest ones. It works like a charm, thank you very much for your help.

MC
0
 
MonteCristo33Author Commented:
Hi Jaffer,

Thank you very much for your contribution. I was already using a similar Case statement based on my option group to enable/disable textboxes. My real difficulty was updating the corresponding field in the linked table, which Scot helped resolve.

As I am working on several projects at the moment, no doubt your knowledge will come in handy at some point.

Thanks again for taking the time to help.

MC
0
 
p912sCommented:
MC,

You're most welcome, glad to help. And thanks for the points and grade.

Scot
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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