dependent fields

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

Guest

How can I make appear a set of fields after an awswer has been chosen? For
instance, if the anwser was yes, then a set of fields appear, and if the
answer was no, a distinct set of fields appear.
 
You will need two queries. One with the fields for Yes and the other with
fields for No.

I don't know where you are answering the question, but let's assume it is a
CheckBox on a form. If so, in the After Update event of the checkbox:
If me.MyCheckBox = True
strQryToUse = "qselYesAnswers"
Else
strQryToUse = "qselNoAnswers"
End If
 
Miguel,

Assuming I understand you correctly, her is an example of code...

Dim YesAnswer As Boolean
YesAnswer = MsgBox("What is the question?", vbYesNo) = vbYes
Me.1stControlToSeeWhenYes.Visible = YesAnswer
Me.2ndControlToSeeWhenYes.Visible = YesAnswer
Me.1stControlToSeeWhenNo.Visible = Not YesAnswer
Me.2ndControlToSeeWhenNo.Visible = Not YesAnswer
 
Hi Klatuu
I get the error Sintax problem when I try t enter the codes you gave me. I
need a little more specific steps.
For instance, how it will recognize the query where the yes fields are and
the query for the no fields are?
The name of my queries are very simple: Yes and No.
I appreciate your help
Thanks
 
Miguel,

When do you want the question to be asked, and when do you want the
visibility of the controls on your form to be adjusted? When you first
open the form? When you move to another record? When you first open
the database? When you click your mouse on a button? Lunch time?
 
Steve:
The question is a check box (yes/no). When the participant answers "yes" I
would like a set of questions to appear next to this field. If the
participant answers "no" I would like a new set of questions to appear next
to this field. The yes/no question is the very first question in the form and
the visibility of the controls to be adjusted should be when I move to the
next field (if that's possible). Here is an example:
Do you work:
yes - no
if answered "yes" then a set of question next to this filed appear in the
form according to this choice.
If the question is answered "no" then a new set of questions appear in the
form next to the first field with choices yes/no.
I hope this is understandable.
This is another question for the choices that Kaluu gave me. I used the
codes that Kaluu gave me about the same question, and I plugged them in the
after update (first choice), but an error message appears about the syntax.
Where should I write these codes in the after update? The first choice? This
is an alternate solution that Kallu gave me.
Thank you for your support
 
Miguel,

In that case, you would write your code on the After Update event
property of the check box. The code would be the equivalent of this...

Me.1stQuestionToSeeWhenYes.Visible = Me.NameOfCheckbox
Me.2ndQuestionToSeeWhenYes.Visible = Me.NameOfCheckbox
Me.1stQuestionToSeeWhenNo.Visible = Not Me.NameOfCheckbox
Me.2ndQuestionToSeeWhenNo.Visible = Not Me.NameOfCheckbox
.... etc
 
Steve:
The words 1st and 2nd are not accepted as codes as I write the following:
Me.1stQuestionToSeeWhenYes.Visible = Me.NameOfCheckbox
Me.2ndQuestionToSeeWhenYes.Visible = Me.NameOfCheckbox
Me.1stQuestionToSeeWhenNo.Visible = Not Me.NameOfCheckbox
Me.2ndQuestionToSeeWhenNo.Visible = Not Me.NameOfCheckbox
..... etc

Is there another way to do it?

Miguel
 
Miguel,

You didn't tell us what are the names of the controls you are referring
to. When I put, for example, 1stQuestionToSeeWhenYes it is to refer to
the name of one of the controls on your form that you want to show when
you tick the checkbox. Similarly, NameOfCheckbox is supposed to refer
to the name of your checkbox. In your code, you are supposed to
substitute the actual names of your controls.
 

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

Similar Threads

make fields Visible or not 4
power schema 2
Count text values in a Access Field 0
Writing an IF/Then statement in a table 11
Date field format 3
How do I delete a dependency 2
Counting Confusion 3
IF STATEMENT 6

Back
Top