Can someone help with this?
I have an option group (radio buttons), with 6 radio buttons. I want the user to have to choose one or more of those buttons before he closes or moves to another record, and if he doesn't do that, he will get a message saying he needs to do this before leaving. I have the following code for it:
Private Sub Form_Close()
Dim No_Buttons_Selected As Boolean
No_Buttons_Selected = False
If Me!RadioButton1.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton2.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton3.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton4.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton5.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton6.Value = False Then
No_Buttons_Selected = True
End If
If No_Buttons_Selected Then
MsgBox "Please select a Radio button"
End If
End Sub
The code runs fine, but if I choose ok from the message (MsgBox) the second time, it allows me to go to the next record or closes the form. I want it to loop with the MsgBox, until the user chooses one of more radio buttons. I tried to do a loop, but I can't get it to work. Does anyone know of more code I can add to the above to get it to do what I want? Please help. Thanks.
Jerome
I have an option group (radio buttons), with 6 radio buttons. I want the user to have to choose one or more of those buttons before he closes or moves to another record, and if he doesn't do that, he will get a message saying he needs to do this before leaving. I have the following code for it:
Private Sub Form_Close()
Dim No_Buttons_Selected As Boolean
No_Buttons_Selected = False
If Me!RadioButton1.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton2.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton3.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton4.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton5.Value = False Then
No_Buttons_Selected = True
End If
If Me!RadioButton6.Value = False Then
No_Buttons_Selected = True
End If
If No_Buttons_Selected Then
MsgBox "Please select a Radio button"
End If
End Sub
The code runs fine, but if I choose ok from the message (MsgBox) the second time, it allows me to go to the next record or closes the form. I want it to loop with the MsgBox, until the user chooses one of more radio buttons. I tried to do a loop, but I can't get it to work. Does anyone know of more code I can add to the above to get it to do what I want? Please help. Thanks.
Jerome