How do I make one field dependent on another?

G

Guest

I have a yes/no field and a text field. I want the text field to be null if
the yes/no field is no and required of the user to enter data if the yes/no
field is yes.

I hope this is clear enough.

Thanks.
 
T

Tim Ferguson

I have a yes/no field and a text field. I want the text field to be
null if the yes/no field is no and required of the user to enter data
if the yes/no field is yes.

Why bother? Just get rid of the boolean field... you already know whether
the text field IS NULL or NOT.

You might want to read more about second and third normal forms.

Tim F
 
S

SusanV

Hi Tim,

I read Jeff's question differently - there's a yes/no box on the form, and
*IF* the user selects "yes" in that box then (and only then) they should
also fill in the textbox and this should be required.
If that's the case, then this should do the trick:

Sub checkbox_OnUpdate

If me.checkbox = False then
me.textbox.required = false
me.textbox.enabled = false
Else:
me.textbox.enabled = true
me.textbox.required = true
End if

End Sub
 
T

Tim Ferguson

I read Jeff's question differently - there's a yes/no box on the form,
and *IF* the user selects "yes" in that box then (and only then) they
should also fill in the textbox and this should be required.

My understanding -- and I don't think it's very far from yours -- is that
the whole question is due to faulty analysis of the question being asked.
To take a concrete (but slightly different) example, consider the sort of
thing:-

"are you married?" --
if the answer is "no", then
please answer "are you single or divorced or widowed?",

You can see that actually there is only one question: the two here both
allude to a single real-life domain (i.e. single, married, divorced,
widowed).

Similarly, the OP is asking the same question twice (if there is a text
value, put it here, if there isn't a text answer, check this). It's bad
informatics and needs to be analysed properly. That is the way I was
trying to steer him.

All the best


Tim F
 
D

Douglas J. Steele

Tim Ferguson said:
My understanding -- and I don't think it's very far from yours -- is that
the whole question is due to faulty analysis of the question being asked.
To take a concrete (but slightly different) example, consider the sort of
thing:-

"are you married?" --
if the answer is "no", then
please answer "are you single or divorced or widowed?",

You can see that actually there is only one question: the two here both
allude to a single real-life domain (i.e. single, married, divorced,
widowed).

What about if the question are "Are you widowed?", in which case the
question would be "How did your spouse die?"
 
J

John Nurick

What about if the question are "Are you widowed?", in which case the
question would be "How did your spouse die?"

Same difference: that's equivalent to the single question

If you are widowed, how did your spouse die? (If you
are not widowed please leave this field empty.)

Which I think brings us to the real point. As far as data storage goes,
the boolean field accompanying the text field is redundant.* But in the
UI it could well be much more effective to split the question and use
the state of the checkbox
Are you widowed?
to control whether the user is required to respond to
How did your spouse die.

*Assuming we can use a zero-length string to indicate not widowed,
leaving NULL for widowed status unknown, and something like "Not Known"
to indicate that the manner of the spouse's death is unknown. If that's
not good enough, maybe the boolean field is needed.
 
S

SusanV

I see your point - thanks for clarifying.

Susan

Tim Ferguson said:
My understanding -- and I don't think it's very far from yours -- is that
the whole question is due to faulty analysis of the question being asked.
To take a concrete (but slightly different) example, consider the sort of
thing:-

"are you married?" --
if the answer is "no", then
please answer "are you single or divorced or widowed?",

You can see that actually there is only one question: the two here both
allude to a single real-life domain (i.e. single, married, divorced,
widowed).

Similarly, the OP is asking the same question twice (if there is a text
value, put it here, if there isn't a text answer, check this). It's bad
informatics and needs to be analysed properly. That is the way I was
trying to steer him.

All the best


Tim F
 
T

Tim Ferguson

What about if the question are "Are you widowed?", in which case the
question would be "How did your spouse die?"

.... then the domain becomes

Single
Married
Divorced
Widowed by drowning
Widowed by electrocution
Widowed by poisoning
Widowed by etc, etc, etc.

It's still a closed set, i.e. mutually-exclusive and (in context)
exhaustive. Eventually, of course, the whole thing becomes a (set of)
entities in its own right, if the semantics of the original business
situation requires it.

Just a thought...


Tim F
 

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

Top