I have 3 radios and 1 ok command.
I dont want the program to progress if either of the 3 remain not selected.
What do I do?I mean the same form should load incase one clicks ok.
Printable View
I have 3 radios and 1 ok command.
I dont want the program to progress if either of the 3 remain not selected.
What do I do?I mean the same form should load incase one clicks ok.
I mean the same form should load incase 1 clicks ok without clicking any radio.
If you want to check the state of 3 radio buttons from your code, you can create a control array.
Something like this.
The only issue I see with this approach is that when the form loads, one of the buttons is bound to be selected. I am sure, there is a way to avoid that, but I am unable to recall it.Code:Private Sub Command1_Click()
For index = 0 To Option1.Count - 1 'Count all the buttons on the screen
If Option1(index).Value = True Then 'Check State of the button
Form2.Show 'Show form.
End If
Next
End Sub
Code:'~~> In Form Load
For Index = 0 To Option1.Count - 1 'Count all the buttons on the screen
Option1(Index).Value = False
Next
Private Sub Command1_Click()
For Index = 0 To Option1.Count - 1 'Count all the buttons on the screen
If Option1(Index).Value = True Then 'Check State of the button
Form2.Show 'Show form.
Exit Sub '<~~ A slight amendment
End If
Next
End Sub
Code:Private Sub Command1_Click()
For i = Option1.LBound To Option1.UBound
If Option1(i).Value = True Then
Form2.Show
Exit For
End If
Next
End Sub
Private Sub Form_Load()
For i = Option1.LBound To Option1.UBound
Option1(i).Value = False
Next
End Sub
Sorry people for replying so late into this(I was stunned by the fact that I managed a soluion!:D:D)but I cracked this using
if .............then
if op1=true then
something
elseif opt2=true the
something
elseif opt3=true then
something
else
again load form1
end if
It did not need loops,see!
If you are using an array of Option1 (like Option1(0), Option1(1), etc...), then all the codes posted by others will be helpful... :)Quote:
Sorry people for replying so late into this(I was stunned by the fact that I managed a soluion!)but I cracked this using
if .............then
if op1=true then
something
elseif opt2=true the
something
elseif opt3=true then
something
else
again load form1
end if
It did not need loops,see!
They had given these codes, thinking that you are using an array of controls... :)
So, casio2000123, please try to give more details of the problem rather than giving three lines... I mean, you have to describe it... :)
Regarding your solution quoted below, it's not necessary to reload the form; it's already there. Just check the radio buttons as you have done already, then End If. That's it. Don't even include the Else clause. That way if none of them are selected it will simply be done with the procedure and not do anything.
Code:If Option1.Value = True And Option2.Value = True And Option3.Value = True then
...........