Consulting

Results 1 to 3 of 3

Thread: Solved: simple question regarding OptionButton Controls

  1. #1

    Solved: simple question regarding OptionButton Controls

    Hi Guys
    I've got two controls set up in a sheet with the following code:

    [VBA]Private Sub OptionButton1_Click()
    Dim intResponse As Integer

    intResponse = MsgBox("You can toggle between the rates to view the effect on the Planning and Tracking modules. However, ensure you select the correct rate every time before posting any figures.", vbYesNo, "Toggle Rate?")

    Select Case intResponse
    Case vbYes
    ' Process commands.
    Case vbNo
    Exit Sub
    End Select
    Call UseCostOHDRates
    End Sub
    Private Sub OptionButton2_Click()
    Dim intResponse As Integer

    intResponse = MsgBox("You can toggle between the rates to view the effect on the Planning and Tracking modules. However, ensure you select the correct rate every time before posting any figures.", vbYesNo, "Toggle Rate?")

    Select Case intResponse
    Case vbYes
    ' Process commands.
    Case vbNo
    Exit Sub
    End Select
    Call UseCORs
    End Sub[/VBA]

    Once a user clicks on say Option 2, and the Dialog box pops up, if they select No, I want the selection to revert back to the Option 1 control. Currently, although the Sub is exited, the selection remains.....

    Is this simple to fix?

    Thanks
    Sunil

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private fReEntry As Boolean

    Private Sub OptionButton1_Click()
    Dim intResponse As Long

    If Not fReEntry Then

    fReEntry = True

    intResponse = MsgBox("You can toggle between the rates to view the effect on the Planning and Tracking modules. However, ensure you select the correct rate every time before posting any figures.", vbYesNo, "Toggle Rate?")

    Select Case intResponse
    Case vbYes
    ' Process commands.
    'Call UseCostOHDRates
    Case vbNo
    OptionButton2.Value = True
    End Select

    fReEntry = False
    End If
    End Sub

    Private Sub OptionButton2_Click()
    Dim intResponse As Long

    If Not fReEntry Then

    fReEntry = True

    intResponse = MsgBox("You can toggle between the rates to view the effect on the Planning and Tracking modules. However, ensure you select the correct rate every time before posting any figures.", vbYesNo, "Toggle Rate?")

    Select Case intResponse
    Case vbYes
    ' Process commands.
    'Call UseCORs
    Case vbNo
    OptionButton1.Value = True
    End Select

    fReEntry = False
    End If
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    many thanks!

Posting Permissions

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