Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / August 2005

Tip: Looking for answers? Try searching our database.

How do I make one field dependent on another?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff H - 29 Aug 2005 13:38 GMT
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.
Tim Ferguson - 29 Aug 2005 13:52 GMT
> 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
SusanV - 29 Aug 2005 14:04 GMT
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

Signature

hth,
SusanV

>> 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
[quoted text clipped - 6 lines]
>
> Tim F
Tim Ferguson - 29 Aug 2005 19:59 GMT
> 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
Douglas J. Steele - 29 Aug 2005 23:14 GMT
>> 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
[quoted text clipped - 12 lines]
> 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?"

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

John Nurick - 30 Aug 2005 07:31 GMT
>>> 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
[quoted text clipped - 15 lines]
>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.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Tim Ferguson - 30 Aug 2005 16:42 GMT
> 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
SusanV - 30 Aug 2005 12:42 GMT
I see your point - thanks for clarifying.

Susan

>> 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
[quoted text clipped - 21 lines]
>
> Tim F
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.