after update code problem

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

Guest

Hi,

I’ve having trouble with my skip pattern. It seems to work ok for the most
part, but my big problem is that it doesn’t seem to reset itself for the next
subject.

Please see my code below. Basically if the subject is under 18, I want to
skip boxes until “question 1.†If the subject is age 18 and over I want to
continue with the questions.

So, if the subject is under age 18, it skips the correct boxes. For the
next subject the skipped boxes from the previous subject are already blocked
out and if I enter an age over 18, I get an error.

Does it have anything to do when the first box after age, “school†is a
yes/no check box?

Or, do I need some “before update†code?

Thanks so much for any help!!!

___________________________________________

Private Sub age_AfterUpdate()


If Me. age < 18 Then
'set the focus to question1 combo box
Me.quest_1.SetFocus
'disable boxes until question1
Me.school.Enabled = False
Me.school_grade.Enabled = False
Me.work.Enabled = False
Me.work_memo.Enabled = False
Me.home.Enabled = False
Else
'set focus to school box
Me.school.SetFocus

End If

End Sub
 
If Me. age < 18 Then
'set the focus to question1 combo box
Me.quest_1.SetFocus
'disable boxes until question1
Me.school.Enabled = False
Me.school_grade.Enabled = False
Me.work.Enabled = False
Me.work_memo.Enabled = False
Me.home.Enabled = False
Else
Me.school.Enabled = True
Me.school_grade.Enabled = True
Me.work.Enabled = True
Me.work_memo.Enabled =True
Me.home.Enabled = True
'set focus to school box
Me.school.SetFocus
End If
 
Hi Doug,

Thanks so much! You are a lifesaver!!

another quick question: for the first skip box ("school" which is a yes/no
check off box) it seems that "no" appears in the table when it is skipped,
but not for the other yes/no check off boxes.

Any suggestions? I would like to leave it blank in the table.

Thanks again!!!

bluesky
 
I'm not sure which of the fields are checkboxes vs. other controls, but what
you can do is set their value to False:

If Me. age < 18 Then
'set the focus to question1 combo box
Me.quest_1.SetFocus
'disable boxes until question1
Me.school = False
Me.school.Enabled = False
Me.school_grade.Enabled = False
Me.work = False
Me.work.Enabled = False
Me.work_memo.Enabled = False
Me.home = False
Me.home.Enabled = False
Else

(I've assume school, work and home are the check boxes)
 
Hi Doug,

Thanks again. I had an error in table. I had "yes/no" for data type, but
then had "text box" instead of "check box" for lookup tab!!! Not is working
perfectly,

thanks again.

-bs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top