Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with Checkboxes

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
0
0
US
I have a very strange issue. I have created various checkboxes to be associated with departmental groups and a main checkbox that unchecked it will check the other checkboxes to see if any are checked and if so throw an message box. the problem is that I have created 7 additional checkboxes and added the code but it throws the error if I try to click on the checkboxes themselves.. Here is my code that works:

Private Sub blnallowidcheckout_BeforeUpdate(Cancel As Integer)
If blnbstseai.Value Or blnbstsmts.Value Or blnbstsdb.Value Or blnbstsests.Value _
Or blnbsmo.Value Or blnbsstaff.Value Or blnbsabap.Value Or blnbschangesup.Value _
Or blnbsfinance.Value Or blnbscommkt.Value Or blnbssupply.Value Or blnsstools.Value _
Or blnsseim.Value Or blnbsqrrc.Value Then
MsgBox "There cannot be any check boxes enabled for any groups to disable this flag. Please uncheck the checkboxes current enabled before proceeding."
Cancel = True
Else
End If
End Sub

When I add the following to it, is when it screws up and once it throws the error if I tried to uncheck any checkboxes it throws the same error.

blnsseim.Value Or blnbsqrrc.Value or _
blniocts.Value Or blnionts.Value Or blnioeurope.Value Or _ blnioasia.Value Or blniobrazil.Value Then
MsgBox "There cannot be any check boxes enabled for any groups to disable this flag. Please uncheck the checkboxes current enabled before proceeding."
Cancel = True
Else
End If
End Sub

Any help would be great!
 
Any chance you could post the error message ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
is not really an error message. I have a message box setup as shown above in the code. That is what it is throwing when i add then new code. it's like it is confused..
 
Both sets of Code look like if any of the bln values are true its going to throw that msgbox. Is that what you want?
 
yes, but for so you would uncheck the boxes and it will not throw it, but when I try to uncheck the added boxes when I add the code it throws it, is there a limit in VBA to how many of "or" you can have?
 
No, I don't think there is a limit.

When you uncheck a checkbox the value of the control will be false, thus the msgbox will not be triggered.

Now if the additional check boxes are enabled and have a true value when one of the primary checkboxes is enabled you may want to do some checking to see if you need to clear and disable the secondary check boxes.

Make sense? If not let me know.
 
you mean on the properties of the checkboxes themselves
 
Yes,

chkbox.enabled = false
chkbox = false ' unchecks the checkbox
chkbox.value = false ' unchecks the checkbox

By doing so you remove set the value to false so that your IF Statement will not display the message box when it is not needed.

Let me know if you need an example.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top