PDA

View Full Version : Solved: Check box prompt



pingwin77
01-05-2009, 12:53 PM
I have a form with 6 to 7 check boxes on it. I need a prompt to come up if all of the boxes are not check. The check boxes do not control anything, I just have the checks there for the operator to verify certain things before continuing. How do I do this?

lucas
01-05-2009, 01:12 PM
If you want them all checked just set them to checked when you initialize the userform.

I can't imagine why you would want them all checked though so I assume your question is poorly worded.

nst1107
01-05-2009, 01:13 PM
Before the form is closed, have a conditional statement check that each textbox = True. Something likeIf Not (CheckBox1 = True and CheckBox2 = True and CheckBox3 = True and etc...) Then MsgBox "Not all checkboxes have been checked."

lucas
01-05-2009, 01:18 PM
Additionally, this seems to be directly related to this thread:
http://vbaexpress.com/forum/showthread.php?t=24073

why would you start a new thread when it is a continuation of the previous project. Do you expect the people trying to help you to follow your posts through the forum to understand your problem?

pingwin77
01-05-2009, 01:34 PM
Lucas, the thread you posted above relates to a different issue and form. I created a new one to help try and eliminate any confusion between the two issues. I am very new to using the forums and to VBA and trying to do the best I can. If this causes a problem I do appologize. If there are any tips to help make this stuff less cluttered I am open to suggestions.

I added the code that NST1107 gave and that works fantastic. I did forget to add something to my first post though. This code is executed by clicking a button which then opens another form. When the button is clicked and the code verifies the check boxes (using the code provided here) and all of the boxes are NOT checked, I need it to stay on the same form so the user can go back and select all the check boxes. If all of them are selected, the the vb code should move on to the next form.

If this does not make sense please let me know and I can try to explain it better.

lucas
01-05-2009, 01:55 PM
Ok pingwin, I'm just trying to help keep the confusion down....

Try this using nst1107's code:

Option Explicit
Private Sub CommandButton1_Click()
If Not (CheckBox1 = True And CheckBox2 = True) Then
MsgBox "Not all checkboxes have been checked."
Else: Unload Me
UserForm2.Show
End If
End Sub

pingwin77
01-05-2009, 02:23 PM
That seems to work! Thanks for all the help. I coldn't do this without help from you guys!

lucas
01-05-2009, 02:25 PM
If you have your solution be sure to mark your thread solved using the thread tools at the top of the page. You can still post followup questions after it's marked solved.

pingwin77
01-05-2009, 04:37 PM
any chance you guys could take a look at the other post that Lucas pointed out earlier? That is the second to last issue I have with this project i'm on.