The option button (1 Viewer)

petercummins

Registered User.
Local time
Today, 13:58
Joined
Sep 6, 2005
Messages
52
Hi peeps,

I am encountering a few problems when I'm using the options button on a form.

Is there a way for the options button to display a different value instead of a -1 when the data is transfered to a linked table? i.e Good or Poor or Fair?

Also can a number of option buttons have the same control souce? at the mintue I have three buttons pointing at one control souce and when I select one of the buttons they all get selected.

Any help will be much appreciated.
 

Rod D

Registered User.
Local time
Today, 05:58
Joined
Feb 9, 2006
Messages
87
An option group is as close as you will get

Peter

The closest you can get to what you have asked for is to create an option group. Look in the toolbox. Assuming you have the wizard enabled, it will guide you through creating it. What it will do is allow you to create as many buttons/radio buttons/check boxes as you like, but only allow the user to select one at a time. This is translated to a single integer and is associated with the option group. You can then make this the record source for a table field.

Have a "play" and see how you go. :)
Hope this helps
Rod
 

petercummins

Registered User.
Local time
Today, 13:58
Joined
Sep 6, 2005
Messages
52
Thanks rod.

Ill have a play about and see what I can find!
 

petercummins

Registered User.
Local time
Today, 13:58
Joined
Sep 6, 2005
Messages
52
Is there anyway Rod to have the option value changed to a word instead of an integer? Or the value to change to a word once it is stored in the table?

This is so the when I run a report from the table I can have the value in the [Bathroom Condition] field to read "Fair" instead of an integer ie 2.
 

Bodisathva

Registered User.
Local time
Today, 08:58
Joined
Oct 4, 2005
Messages
1,274
An option button can only evaluate to "TRUE" or "FALSE", an option group uses the TRUE or FALSE condition to determine the numeric only value for the group. For what you want to do, you must decode the value in order to place the text. Assume that you create an option group called grpBathroom, you would place the following in the On_Click event:
Code:
Private Sub grp_Click()
     Dim strCondition As String
     
     Select Case grpBathroom
          Case 1
              'something
          Case 2
              strCondition = "Fair"
          Case 3
              'something else
          Case Else
              'strCondition = "UNKNOWN"
      End Select

      [Bathroom Condition] = strCondition
End Sub
 

petercummins

Registered User.
Local time
Today, 13:58
Joined
Sep 6, 2005
Messages
52
Private Sub grpBath_Click()
Dim strCondition As String
BathCondition = strCondition

Select Case grpBath
Case 1
strCondition = "Good"
Case 2
strCondition = "Fair"
Case 3
strCondition = "Poor"
Case Else
strCondition = "UNKNOWN"
End Select
End Sub
I have this as my code. It's not working. Can you see where I am going wrong? As you have probably guessed coding is not one of my strong points!
 

Bodisathva

Registered User.
Local time
Today, 08:58
Joined
Oct 4, 2005
Messages
1,274
you are assigning the value of strCondition to BathroomCondition while the string is still null. Change to this:
Code:
Private Sub grpBath_Click()
    Dim strCondition As String
     Select Case grpBath
          Case 1
              strCondition = "good"
          Case 2
              strCondition = "Fair"
          Case 3
              strCondition = "poor"
          Case Else
              strCondition = "UNKNOWN"
      End Select
    
    [COLOR="Red"]BathCondition = strCondition[/COLOR]
End Sub
 

petercummins

Registered User.
Local time
Today, 13:58
Joined
Sep 6, 2005
Messages
52
Thats seems to be working now thanks BUT on the form now there is no black dot appearing in the option buttons. They just seem to have a grey scale and when the form reopens they are all selected.

Any ideas????????
 

ansentry

Access amateur
Local time
Today, 22:58
Joined
Jun 1, 2003
Messages
995
Search and you shall find!

Have a look at my sample I posted here - Second from the bottom, no coding required.

Click Here
 

Rod D

Registered User.
Local time
Today, 05:58
Joined
Feb 9, 2006
Messages
87
Hi Peter

Sorry for not replying sooner - I've been away.
What I had in mind was storing the state of the option group in the table as an integer (1-4 say) and have the option buttons labels have the Good, Fair, Poor, Unknown text. That way, whenn you scroll through the records, the option boxes will change (as you would see with Johns example above).

When you print the report, then you have 2 options - either calculate the text in the query or directly in the report.

I would have used something like the Choose function to calc the text in either scenario.

i.e =Choose([<option grp field name>],"Good","Fair","Poor","Unknown")

No code needed!

Regards
Rod
 

petercummins

Registered User.
Local time
Today, 13:58
Joined
Sep 6, 2005
Messages
52
Cheers for your replies. What I really want is what Bodisathva has helped me with, changing the values to words in the fields that show up in the table. I need it because I will be using them values to transfer to a total different system later in the year.

All thats happening now though is that the formula he used is working but the Option Group box is not showing the dotted values when I search through the records.

Might have to choose one or the other now and cant get it the way I wanted it!
 

ansentry

Access amateur
Local time
Today, 22:58
Joined
Jun 1, 2003
Messages
995
Peter,

Just a couple of points (if you don't mind);

Why do something the hard way when the sample I posted shows you the easy way (and I feel the correct way).

I will be using them values to transfer to a total different system later in the year.
In the sample I posted have a look at the query qryDetails, doesn't that show you what you would want to transfer out of Access.

Now if you must do it the other way;

Your would have to have code in both the "OnCurrent" event of the form and "After Update" of the option group (Frame).

You would have to store the Option value in the table so that when using the form to scroll through the records the values will be reflected in the option group.

As you want a Text version of the value, you will have to also store that in the table, so that you have something to export when you move the data.

You appear to have your code under;
Private Sub grpBath_Click()

What is grpBath?

I have knocked up a sample (against my better judgement) so if you can't get it to work post back and I will post the sample.
 

petercummins

Registered User.
Local time
Today, 13:58
Joined
Sep 6, 2005
Messages
52
thanks John,

grpBath is the option group. I will look further into your sample. thanks for your help on this.
 

petercummins

Registered User.
Local time
Today, 13:58
Joined
Sep 6, 2005
Messages
52
Thanks John.

I have created it in the way you posted. It was the most simplest and I can convert the results at a letter date now with the simple query.

Do you know if it is possible to totally uncheck the option buttons in an option group if you dont want anything selected? because when I select one option it I cant uncheck it.
 

ansentry

Access amateur
Local time
Today, 22:58
Joined
Jun 1, 2003
Messages
995
Have a look at the updated sample.

I have given you 2 options (no pun intended)

Any questions post back and I or someone else will answer you query.
 

Attachments

  • Option Group 240506A.zip
    27.7 KB · Views: 143

sub_nitrox

Registered User.
Local time
Today, 14:58
Joined
Sep 28, 2006
Messages
20
Who has idea of why with the solution proposed (referred to the Case Selection code), the checkbox are not visualized correctly in the form, in the sense that the user is not able to see the checkbox selected but the value is stored correctly in the table?

Thanks for any suggestion.
Cheers,
Antonio.
 

Users who are viewing this thread

Top Bottom