Creating a constrain using age range

Hi All,
I am trying to put a constraint to a question based on an answer to a preceding question.
Example:
q1. What is the age of the child in Months_____[Child_Age] (Hint: Child age MUST be between 0-59 months)

q2. Did the health care provider talk to you about feeding your child with at least 4 food groups a day (This question should be relevant of the child is aged between 7 months and 59 months).

I have tried the following options with the relevant column but it does seem to work:
a) ${Child_Age} >=7 and <=59
b) ${Child_Age} >=7 and ${Child_Age} <=59

Both options returns an error. What am I not doing right?
Alex.

Hello,
b) should work. (Could you verify, that the relevant text is exactly the same as in your message here?)
So, the error source might be elsewhere. Could you provide the error message, please?
Kind regards

1 Like

Hi @AlexRutto77,

As advised by @wroos, you could do the same as outlined in the image below:

In the survey tab of your xlsform:

In the choices tab of your xlsform:
Image 2

Data entry screen as seen in Enketo: When a wrong entry is attempted!

Data entry screen as seen in Enketo: When a correct entry is made!

Reference xlsform:
Constraint.xlsx (9.7 KB)

Have a great day!

@wroos @Kal_Lam thanks both. It worked. I was missing a letter in one of the variables.

2 Likes