Check box update

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

Guest

I currently have a list of questions within a form and one question is
related to the previous one.
Should the answer to the previous question be No then I want the next
question to be accessible. Should it be yes then I would like the question
box to be greyed out and locked.
How would I go about this?
Many Thanks,
Matt
 
Use the Click event of the CheckBox to enable/disable the other control.

If Me.chkBox Then '-- CheckBox is checked!
Me.OtherControlName.Enabled = True
Else '-- CleckBox is unchecked
Me.OtherControlName.Enabled = False
End If

Using your OtherControlName of course and adjust the logic to suit your form.
 
Use the After Update event of the first check box.
Me.SecondCheckBox.Enabled = Not Me.FirstCheckBox
 
Put code in the AfterUpdate event of the checkbox to disable the question.
Assuming you want Question 3 disabled if the answer to Question 2 is No,
try:

Private Sub chkQuestion2_AfterUpdate

Me.chkQuestion3.Enabled = Me.ChkQuestion2

End If
 
Ruralguy,

Many Thanks, however
Is there anyway, in case of error that say if the checkbox had been checked
and then unchecked that the dependent could switch back and forth.
At present if checked the question greys out, but if it is unchecked it
still remains this way.
Matt
 
Sorry i phrased it badly
I was still talking about Questions one and two. If the box was checked then
the question two would grey out. If i then unchecked the box, the question
two would not return. I am only worried about this in case of error!
Matt
 
Also, if i exit the form and come back in, this data does not remain, for
example if it had previously been greyed out, i could come back in and the
box would still be chekced but question 2 no longer greyed out
 
The code all of us supplied *should* toggle the next control.enabled. In
order for the form to remember the enabled state of the controls you will
need some code in the OnLoad event (or maybe current event if several records
are involved) that tests the state of the CheckBoxes and sets the enabled
property of the various controls. If the toggle does not work the post back
because it *will* work!

Matt said:
Also, if i exit the form and come back in, this data does not remain, for
example if it had previously been greyed out, i could come back in and the
box would still be chekced but question 2 no longer greyed out
Put code in the AfterUpdate event of the checkbox to disable the question.
Assuming you want Question 3 disabled if the answer to Question 2 is No,
[quoted text clipped - 14 lines]
 
Did you try the code? Since there's code in the AfterUpdate event of
chkQuestion2, unchecking it will disable Question 3, and checking it will
enable Question 3.
 
In that case, you also need

Me.chkQuestion3.Enabled = Me.ChkQuestion2

in the form's Current event.
 
Right,

Apologies for the long break, I dont have the internet at home.

That code does not appear to work Douglas. I am still having a problem in
that I cannot toggle the value and also if i leave the form and come back in
the value does not remain!

Any more help guys?
 
Exactly what code did you put in what events?

(Note: I'm leaving for a trip in a matter of minutes, so it might be as long
as a week before I get back to this thread)
 
Have a nice trip Doug. Matt, there are others watching this thread as well.
Exactly what code did you put in what events?

(Note: I'm leaving for a trip in a matter of minutes, so it might be as long
as a week before I get back to this thread)
[quoted text clipped - 42 lines]
 
Back
Top