Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Group

Status
Not open for further replies.

mommom

Technical User
Nov 14, 2003
208
US
For the Option Group I have

Fulltime
Partime
Temporary

Is there a way that a person is only allowed to click on one?
 
That is the way an Option Group works: you are only allowed to select one option. What is the problem?
 
You mean that he cannot click at all on the other 2, or like remou said, that you cannot click on 2 or 3 of them at the same time?

Haerion
 
You can select All three. Want it that a person can only select One.
 
sounds like you created your own option group instead of using the selection from the Toolbar.

PaulF
 
Paul - when I do it through the toolbar; when I go out of the database and come back in the option I selected was no longer there.
 
mommom
I'm a little confused with your problem. Is it:
1. being able to select all 3 items inside an option group at the same time, when only one is suppose to be allowed?,

or

2. is it the fact that the item selected was not stored in your data?

If it is #1 then I'd say that you didn't use the Option Group icon on the toolbar to create the Option Group and created one using checkboxes or radio buttons. Using the Option Group control from the toolbar will only allow the user to select one option. You can select more than one but each time you select an option any previously selected option will be de-selected (if that makes any sense).

If it is #2 then the problem is not having the Option Group bound to the field in your RecordSource.

If it is neither than please provide more of an explanation.

PaulF
 
It is number 2. How would I go about bounding the field in the RecordSource?
 
mommom

As long as the field you want to update is included in the RecordSource you use the AfterUpdate Event of the Option Group as in this example
Where the Option Group is name optStatus, and the name of the field in the table/RecordSource is Status.
If you entered FullTime, PartTIme and Temporary in that order into the Option Group then FullTime will have a value of 1, PartTime has a value of 2 and Temporary has a value of 3.
I capture the value of the Option Group and then when the Form is Update (or move to a new record), I reset the Option Group Value to 0 so nothing is shown as being selected when I go to the new record.

Private Sub Form_AfterUpdate()
Me.optStatus = 0
End Sub


Private Sub optStatus_AfterUpdate()
Select Case optStatus
Case 1
Me!Status = "FullTime"
Case 2
Me!Status = "PartTime"
Case 3
Me!Status = "Temporary"
End Select
End Sub


PaulF
 
To me, it is much easier to simply bind the option group to the field you want updated. Make sure that the wizard wand is clicked and add an option group to your form:

1. Fill in the labels you want (Full Time, Part Time, etc).
2. Choose a default value, if you want one.
3. Fill in the values you want. These are automatically assigned by Access as 1,2,3, etc in the order that you entered the labels, but you can change them to any other numbers: 5,1,307, if it suits. You will not be able to use text values.
4. Choose 'Store the value in this field' and select the field you want to store the values you assigned at (3) above, that is, the bound field.
5. Choose a style for your buttons.
6. Name the control.

And there you are.
 
Thats great if you want to store 1, 2 or 3 in your field instead of Fulltime, Parttime, Temporary. But then you'd have to convert 1 back to Fulltime, etc in all reports, forms and querys. Easier to store the string value at the time you generate the record then to "remember" what the value 1 stands for 2 years down the road.

PaulF
 
To All

How about in the [blue]AfterUpdate[/blue] event of the option group:
Code:
[blue]   Me![purple][b][i]BoundTextboxName[/i][/b][/purple] = Choose(Me![purple][b][i]OptionGroupName[/i][/b][/purple], Fulltime, Parttime, Temporary)[/blue]

Calvin.gif
See Ya! . . . . . .
 
PaulF
I can see your point, especially in this case, but it is more usual to store numbers and keep reference tables.
 
Hello Paul,

I did what you said, see below but I am getting the following error.

The expression AfterUdate you entered as the event property setting produced the following error: Ambiguous name detected: SelectOne_AfterUdate

Private Sub SelectOne_AfterUpdate()
Me.SelectOne = 0

End Sub

Private Sub SelectOne_AfterUpdate()
Select Case SelectOne
Case 1
Me!Status = "Fulltime"
Case 2
Me!Status = "Parttime"
Case 3
Me!Status = "Temporary"
End Select

End Sub
 
mommom
sorry it took so long to reply, but

Private Sub SelectOne_AfterUpdate()
Me.SelectOne = 0

End Sub

isn't what I typed

it should be in the Form's AfterUpdate

Private Sub Form_AfterUpdate()
Me.SelectOne = 0

End Sub


PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top