linking yes/no field.

A

antonio

This question is an offshoot of a previous posting from
the 18th. I have a form that contains a yes/no field and a
seperate text data field. Is there a way to link the
yes/no field (it is a check box) to another the data field
so that when the check box is marked (set to true), the
back round color of the data field changes from white to
blue or green or whatever?

Example:
Yes/No datafield = "Occupied"
Regular text datafield = "Occupant Name"
When Yes/No data field is true (box is checked), the back
round color changes from white to blue whether or
not "Occupant Name" has data in it or not.

Thanks so very much for any help in advance...
Antonio
 
H

HSalim

Antonio
If it is YesNoField the only possibilities are Yes (-1) and No (0)
Anyway, use this code in the form's current event
substituting your field/control names as applicable
if me.yesnofield then
me.txtOccupied = "occupied"
me.txtOccupantName.BackColor = 65535
Else
me.txtOccupied = ""
me.txtOccupantName.BackColor = 16777215
End if
 
A

Antonio

I am having trouble with the code you provided. Its my
fault as I think I was unclear win my original message....
The first data field is a yes/no field. This yes no check
box is called "occupied". Each time this box is checked
off (or equal to -1, right?) I want the backround color of
txtOccupantName to be white.
I attempted to paste the code into the On Current but I
got an error message from the "de-bugger" stating "invalid
use of null" or something of the like. I really appreciate
you help.
Antonio
 
A

Antonio

Would it cause problems if there were more than one yes/no
fields on the form? Would they all respond the same?
 
H

HSalim

Antonio,
Try this: You will learn much faster if you tried to understand the code
that is being suggested, and to experiment with it
when it does not work.

HS
'--------------------------------------

If not ISNull(Me.Occupied) then
if Me.Occupied <> 0 then
me.txtOccupantName.BackColor = 16777215 ' white
me.txtOccupantName.BackStyle = "Solid"
Else
me.txtOccupantName.BackColor = 0 'Black - or use any other color you
like
me.txtOccupantName.BackStyle = "Transparent"
End if
Else
me.txtOccupantName.BackColor = 0 'Black - or use any other color you
like
me.txtOccupantName.BackStyle = "Transparent"
End if
 

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