By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

How do I get the dot to appear when an option button is selected?

P: 5
Hi,

I'm new here and have a bit of a problem. I'm building a form in Access 2003 and have a piece of code I'm using to ensure that the correct values are saved in the table when each option is selected. This was the original code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub AdministrativeSoundness_AfterUpdate() 
  2.     Select Case AdministrativeSoundness 
  3.         Case 1 
  4.             'Green 
  5.             Me.AdministrativeSoundness = "15" 
  6.         Case 2 
  7.             'Amber 
  8.             Me.AdministrativeSoundness = "7.5" 
  9.         Case 3 
  10.             'Red 
  11.             Me.AdministrativeSoundness = "0" 
  12.         Case Else 
  13.     End Select 
  14. End Sub 
For some reason when I use the above, the dot that shows the option button has been selected doesn't appear. So, based on a response to a question someone else had, I tried this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub AdministrativeSoundness_AfterUpdate() 
  2.     Select Case AdministrativeSoundness 
  3.         Case 1 
  4.             'Green 
  5.             Me.AdministrativeSoundness = "15" 
  6.             Me.optASGreen.Visible = True 
  7.         Case 2 
  8.             'Amber 
  9.             Me.AdministrativeSoundness = "7.5" 
  10.             Me.Option961.Visible = True 
  11.         Case 3 
  12.             'Red 
  13.             Me.AdministrativeSoundness = "0" 
  14.             Me.Option963.Visible = True 
  15.         Case Else 
  16.     End Select 
  17. End Sub 
Unfortunately, I still don't get my little green dot, which I really need so that the users know they have answered that question. I have also tried separating the two actions by putting the 'visible =True' bit into an event procedure on the AdministrativeSoundness_Click event, but that didn't work either.

Can anyone tell me what I'm doing wrong? I know it's got something to do with the select case function, which I need in order to get the decimal value into the table, because it doesn't happen on the form tabs where I can just key the value I want directly into the option button's properties field. It only happens on the tabs where I need to use the select case statement.

I'm self-taught in Access, and until I started building this database, I'd managed to avoid VBA, so I'm not really sure that I'm going about this the right way.
Aug 31 '08 #1
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
If AdministrativeSoundness is an Option Group, its value can only be an Integer, hence the Case 1, Case 2, etc. These Integer values are assigned by Access when the group is created, so yours would be

Green 1
Amber 2
Red 3

But you’re then immediately assigning different values to AdministrativeSoundness, and string values at that:

Green 15
Amber 7.5
Red 0

Since these values don’t have a corresponding option button in AdministrativeSoundness, no option button is selected, i.e. no button has a black dot showing.

Your choices here are

Have the Option Group be unbound, then assign your values of 15, 7.5 and 0 to AdministrativeSoundness.

or

Let Access store the values of 1, 2 and 3 in your table, and then “translate” these values, when needed, into the output you want ( 15, 7.5, 0) in an unbound textbox with a Select Case similar to what you already have, except you assign the output to the unbound textbox.

Expand|Select|Wrap|Line Numbers
  1. Private Sub AdministrativeSoundness_AfterUpdate() 
  2.     Select Case AdministrativeSoundness 
  3.         Case 1 
  4.             'Green 
  5.             Me.DisplayAS = "15" 
  6.         Case 2 
  7.             'Amber 
  8.             Me.DisplayAS = "7.5" 
  9.         Case 3 
  10.             'Red 
  11.             Me.DisplayAS = "0" 
  12.         Case Else 
  13.     End Select 
  14. End Sub 
where DisplayAS is the unbound textbox.

Welcome to Bytes!

Linq ;0)>
Aug 31 '08 #2

P: 5
Thanks so much. It's fixed now and a great relief. Thanks again.
Sep 1 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
Always happy to help a lady! Are you perhaps the ladycyradis from "down under?"

Linq ;0)>
Sep 1 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.