jrobin5881
Technical User
Good Morning,
I have a user form with several command buttons on the bottom and two option buttons. When my user clicks a button I am checking to make sure that they've made at least one selection in the option buttons before continuing on with the program. I wrote the sub below and inserted into the topline of each of the command button Click event. It works fine in that the message pops if the user has not selected any of my option buttons but my problem is that it the code continues on in the Click event after running the sub routine. My question is how do I get the code to stay in the Optcheck sub without moving back to the click event and until my user selects a option button? Do I need a looping statement? and if so where?
I have a user form with several command buttons on the bottom and two option buttons. When my user clicks a button I am checking to make sure that they've made at least one selection in the option buttons before continuing on with the program. I wrote the sub below and inserted into the topline of each of the command button Click event. It works fine in that the message pops if the user has not selected any of my option buttons but my problem is that it the code continues on in the Click event after running the sub routine. My question is how do I get the code to stay in the Optcheck sub without moving back to the click event and until my user selects a option button? Do I need a looping statement? and if so where?
Code:
Private Sub Optcheck()
Dim response As Long
If opt1.Value = False And opt2.Value = False Then _
response = MsgBox("Please select a reporting period", vbRetryCancel + vbCritical + vbDefaultButton1, "Performannce Planning Tool")
If response = vbCancel Then
Exit Sub
ElseIf response = vbRetry Then
frmMain.fra1.SetFocus
End If
End If
End Sub