Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Radio Buttons (Access 2000)

    I have radio buttons with 2 options Main or Service , and I want each option to apply a filter like this...

    Private Sub serviceopt_GotFocus()
    Filter = "[Main_Service] = 'S'"
    Me.FilterOn = True
    End Sub

    When I do this it will not work, help?!

  2. #2
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Radio Buttons (Access 2000)

    I don't know but could it be the ' and the " are backwards after the S on line two? Fay

  3. #3
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Radio Buttons (Access 2000)

    No that wasnt it, but thanks for the thought.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Radio Buttons (Access 2000)

    If you have option buttons, they should be part of an option group frame, otherwise they won't act correctly. The best way to design them is using the Wizard.
    You don't handle the Got Focus event of each option button, but the On Click or After Update event of the option group. Each option button in an option group has an Option Value; the Value of the option group as a whole is the Option Value of the selected option button.

    So say that you have an option group grpSelect with an option button labeled "Main" with option value 1, and an option button labeled "Service" with option value 2. You could use code like this:

    Private Sub grpSelect_AfterUpdate()
    Select Case grpSelect.Value
    Case 1
    Me.Filter = "[Main_Service]='M'"
    Case 2
    Me.Filter = "[Main_Service]='S'"
    End Select
    Me.FilterOn = True
    End Sub

  5. #5
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Radio Buttons (Access 2000)

    That worked perfectly, except that the first time i change it, it does nothing, the second time it works, Its defaulted to Main, and the first time I click Service it doesnt work, but if I click main again and go back to service it works and will keep working, i am not sure why, i also tried it with the On Click event and it did the same thing?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Radio Buttons (Access 2000)

    Clear the DefaultValue property of the option group. This will make both option buttons come up gray initially, and the code will fire the first time you click one of them.

    (Although if the default is Main, it should work the first time too if you click Service...)

  7. #7
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Radio Buttons (Access 2000)

    That did it, thanks Hans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •