If you mean the Visible property of the text box, it doesn't really matter,
because you are changing it on each record.
Since I don't know what your control names really are, I made some up, but
the code I posted should work. Did you put it in the Current event of the
form?
One thing I did leave out, is how to handle new records. As is, it would
display the control for new records.
One other thing is how you worded your original post. You first said:
"I have a text box in a form and I would only like it to display data if a
seperate field in the table is True"
This would indicate a Boolean(Yes/No) data type field.
Then you said:
"I only want it to display when Tbl_Hotels.[Brand] = "RD""
Now we are talking about a text field. I did write the code for the text
field. Remember, when you are working in a form, you don't use the table's
field names. You use the form's control names. If you use the form wizard or
drag the fields off the field list onto the form, Access gives the control
the same name as the field. This is bad. Not only can it confuse us humans,
Access can sometimes get it wrong. So be sure your naming is good and you
are using the form control names.
Now here is the explanation:
This part:
Me.txtBrand = "RD"
will return True if the control is equal to "RD" and False if it is not
This part:
Me.txtRequiredProductReference.Visible =
Will set the Visible property of the control based on what is on the right
of the = sign.
So if you say:
Me.txtRequiredProductReference.Visible = Me.txtBrand = "RD"
it will evaluate the expression on the right side of the first = and return
either True or False, thus setting the Visible property.
We put it in the form's Current event because it fires every time the
current record changes. This includes when you open the form.
Sorry, but I know that works, it is a matter of getting the naming correct
and looking for the proper value.
--
Dave Hargis, Microsoft Access MVP
Chris said:
I tried that and they did not display. Do I have to set the visible field to
Yes?
:
Use the form's Current Event. You posted field names, but those wont help.
You need to use the form's control names. Making up "guess " names, it would
be something like:
Me.txtRequiredProductReference.Visible = Me.txtBrand = "RD"
--
Dave Hargis, Microsoft Access MVP
:
I have a text box in a form and I would only like it to display data if a
seperate field in the table is True. Is this something that can be done?
Example.
Tbl_PIP_Items.[Required Product Reference] is loaded in a form. I only want
it to display when Tbl_Hotels.[Brand] = "RD". Can this be done?