Value in a field sets the value of another field

Value in a field sets the value of another field

Post by Q2xkZGxlb3 » Wed, 11 Apr 2007 00:02:03


I have a field "NT" which is a number and another field "STM" which is a
yes/no value. I would like the STM field to be set to true/yes when the value
in NT=6. How do I do this? I've spent some time looking for help on the
boards, but nothing seemed quite suitable (or comprehensible to me, at
least). Thanks for your help!
 
 
 

Value in a field sets the value of another field

Post by Jeff Boyc » Wed, 11 Apr 2007 01:11:21

If you are saying that knowing the value of the [NT] field will ALWAYS
determine the value of "STM", then don't bother!

You don't mention whether this is happening in a form or a query or a report
or a table (?or in code).

Regards

Jeff Boyce
Microsoft Office/Access MVP

 
 
 

Value in a field sets the value of another field

Post by Q2xkZGxlb3 » Wed, 11 Apr 2007 03:26:03

This is happening in a form. So when the user inputs 6 in the NT field, the
STM field becomes true. Other values could be either true or false as
determined by usere.
 
 
 

Value in a field sets the value of another field

Post by Jeff Boyc » Wed, 11 Apr 2007 03:40:51

That seems to confirm my impression... the value of STM is solely dependent
on the value of [NT]. Therefore, you do not need to store STM, since
knowing [NT] will suffice.

You could add code to the AfterUpdate event of [NT] that would DISPLAY a
value for STM, but you would not need to store the STM value. In fact, if
you DID store the STM value, your data integrity would be at risk, since it
would be (at least theoretically) possible that someone could change one or
the other of these two fields and not know or remember to update the other.

If you add an upbound checkbox control to your form (e.g., chkSTM), and have
a control bound to your [NT] field (e.g., txtNT), then your code would look
something like:

If Me!txtNT = 6 Then
Me!chkSTM = True
Else
Me!chkSTM = False
End If

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
 
 

Value in a field sets the value of another field

Post by Q2xkZGxlb3 » Wed, 11 Apr 2007 04:02:02

Just to clarify, for other values of NT, STM could be true or false,
depending on what the user chooses. Also, in extraordinary circumstances, the
user might want to choose STM to be false, even if NT is 6. Thus, STM is not
solely dependent on the value of NT.