As June7 said, creating an Option Group for your buttons will allow the Access Gnomes to do all of the heavy lifting for you! In Form Design View:
- Click on the Option Group Icon and place on Form (Under the Design Tab on the Ribbon)
- Follow the Wizard and enter the Caption for each Button
- Hit 'Next'
- Select "No, I don't want a Default'
- Hit 'Next'
- Hit 'Next' (Yes, hit it a second time to accept the Given Values)
- 'Option Buttons' is the Default type of Control, so hit 'Next' again
- Enter the Caption you want to appear above the Option Group
- Hit 'Finish'
Now, to use the option that is chose, something like this:
Code:
Private Sub Frame0_AfterUpdate()
Select Case Me.Frame0
Case 1
'Code goes here for when the first button is selected
Case 2
'Code goes here for when the second button is selected
End Select
End Sub
Replace Frame0 with the actual name Access assigns to the Option Group; it will be 'Frame' followed by one or more digits.
Place whatever code you want to run when each button is selected in the designated place under the 'Cases.'
Access will now only allow one Option to be selected from the Group.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007