Check box question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that uses check boxes for categories and sub-categories. I want the form to automatically check the main category if a sub category is checked. I can do this with the following code

Private Sub accountant_Click(
[professional] =
[business] =
End Su

The problem is that if a user makes a mistake and checks the wrong sub-category check box then unchecks it, I want it to also uncheck the main category. I can't seem to get this to work.
 
Basically, you will write an If statement against each sub-category check
box using the OnClick Event. For example.

If professional = True Then
categoryname= True
Else
categoryname = False
End If

If business = True Then
categoryname=True
Else
categoryname = False
End if

Where categoryname is the name associated with your sub-category.

Michaelann said:
I have a form that uses check boxes for categories and sub-categories. I
want the form to automatically check the main category if a sub category is
checked. I can do this with the following code:
Private Sub accountant_Click()
[professional] = 1
[business] = 1
End Sub

The problem is that if a user makes a mistake and checks the wrong
sub-category check box then unchecks it, I want it to also uncheck the main
category. I can't seem to get this to work.
 
You could also write a double If also.
If professional = True Then
If category = False Then
category= True
Else
category = False
End If
End If

Air code, may need some tweaking.

Michaelann said:
I have a form that uses check boxes for categories and sub-categories. I
want the form to automatically check the main category if a sub category is
checked. I can do this with the following code:
Private Sub accountant_Click()
[professional] = 1
[business] = 1
End Sub

The problem is that if a user makes a mistake and checks the wrong
sub-category check box then unchecks it, I want it to also uncheck the main
category. I can't seem to get this to work.
 
The value property for a check box is boolean; either true
or false so you should try something along the following lines

Private Sub account_Click()
[professional] = True
[business] = True
[another check box] = False
End Sub

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
I have a form that uses check boxes for categories and
sub-categories. I want the form to automatically check the
main category if a sub category is checked. I can do this
with the following code:
Private Sub accountant_Click()
[professional] = 1
[business] = 1
End Sub

The problem is that if a user makes a mistake and checks
the wrong sub-category check box then unchecks it, I want
it to also uncheck the main category. I can't seem to get
this to work.
 
Use the value of the checkbox that is checked to set the main checkbox IE
Private Sub accountant_Click()
[professional] = [accountant]
[business] = [accountant]
End Sub

Hope this helps....
Blaire
http://www.codewidgets.com

Michaelann said:
I have a form that uses check boxes for categories and sub-categories. I
want the form to automatically check the main category if a sub category is
checked. I can do this with the following code:
Private Sub accountant_Click()
[professional] = 1
[business] = 1
End Sub

The problem is that if a user makes a mistake and checks the wrong
sub-category check box then unchecks it, I want it to also uncheck the main
category. I can't seem to get this to work.
 
Back
Top