Need Code attached to Command Button


Posted by Rick M on March 20, 2001 6:08 PM

I am creating a quiz sheet. I have a command button with a macro to go the next question. Is there code that would not allow the user to go to the next question unless there was a least one answer check?

I am using one question per worksheet, with check boxes to select the answers and a command button to "submit answer and go to next question".

Thanks



Posted by Dave Hawley on March 21, 2001 12:47 AM

Hi Rick

Here is one method. Lets assume you have 3 choices per question. Set all Enabled properties to false, except the first 3 Checkboxes for question 1.

Then for question 1 Checkboxes use some code like this:

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then Run "Step2"
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then Run "Step2"
End Sub
Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then Run "Step2"
End Sub

Then in a normal module put:

Sub Step2()
Sheet1.CheckBox4.Enabled = True
Sheet1.CheckBox5.Enabled = True
Sheet1.CheckBox6.Enabled = True
End Sub


This will only allow the user to move down to question 2 IF they have made a choice for question 1. Do the same for all questions


Dave

OzGrid Business Applications