Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-30-2016, 04:53 AM
unwanted unwanted is offline Using check boxes and moving to start of document Windows 7 64bit Using check boxes and moving to start of document Office 2013
Novice
Using check boxes and moving to start of document
 
Join Date: May 2016
Posts: 2
unwanted is on a distinguished road
Default Using check boxes and moving to start of document

Hello I just have a couple of questions about checkboxes.

I'm currently putting in a kind of multiple choice quiz into a document. I have some questions with the check boxes bellow them and at the end a button to press to submit it and one to reset it.

I used the follow VBA on the submit button where the Correct answer was the 2nd choice:

If checkbox2.Value = True Then
answer1.Caption = "Correct"
Else
answer1.Caption = "Incorrect"
End If

Now if the correct box is checked then it says "Correct" and if any of the incorrect boxess are checked then it says "Incorrect" like it should, however, if both the correct and an incorrect box are checked it still comes up "Correct". I only want it to say "Correct" if only the correct answer is chosen and nothing else.

I have got around the problem with the following code:

If checkbox2.Value = True Then
answer1.Caption = "Correct"
Else
answer1.Caption = "Incorrect"
End If

If checkbox1.Value = True Then
answer1.Caption = "Incorrect"
End If

If checkbox3.Value = True Then
answer1.Caption = "Incorrect"
End If

If checkbox4.Value = True Then
answer1.Caption = "Incorrect"
End If

That works fine so if the wrong box or any other boxes are checked along with the correct box it will display "Incorrect" but is quite cumbersome (and will be quite time consuming to do it over multiple documents with lots of questions) so is there a way to add a kind of clause to the statement so it does something like:

If checkbox2 = True AND checkboxes 1,3,4 = False Then
answer1.Caption - "Correct"
Else
answer1.Caption = "Incorrect"
End If


Secondly I have some questions where you have to select two or three of the answers, so if in the example above the answers were boxes 2 and 4, how would I make it display "Correct" only when both boxes are checked and "Incorrect" if one of the incorrect are checked or there is only one box checked?

The best I can come up with is this, where it works fine if both correct answers are chosen, no correct answers are chosen or only checkbox2 is chosen (as in it displays "Incorrect" because both answers arn't chosen), but if I have checkbox4 chosen and any incorrect answer or no other answer, it displays "Correct" instead of "Incorrect".

If checkbox2.Value = True Then
answer1.Caption = "Correct"
End If

If checkbox4.Value = True Then
answer1.Caption = "Correct"
Else


a8.Caption = "Incorrect"
End If

If checkbox1.Value = True Then
answer1.Caption = "Incorrect"
End If

If checkbox3.Value = True Then
answer1.Caption = "Incorrect"
End If


And lastly I can't seem to find anything with google for doing something as simple as making the "submit" button also go to the top of the document when it is clicked.

Resolution: use an "And" statement within the IF e.g.

Code:
If q1c.Value = True And q1a = False And q1b = False Then
   a1.Caption = "Correct"
Else
  a1.Caption = "Incorrect"
End If
I tried that before and it wouldn't accept the "And" but now it is accepting it no problem.

Last edited by unwanted; 05-30-2016 at 11:40 PM. Reason: resolution
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro (or something) to run Spell Check within rich text content boxes in lock document NMBELL Word 8 12-21-2015 04:09 PM
Word2010 check boxes and plain text content control boxes in same table fcsungard Word 5 06-01-2012 01:16 AM
Using check boxes and moving to start of document Check boxes display funkyspirit Word 3 05-23-2012 08:39 AM
Using check boxes and moving to start of document Check Boxes jellyrolls Office 4 07-15-2011 08:07 PM
Problem with Developer Form -- Check Boxes and Text Boxes PCC Word 1 05-16-2009 05:22 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft