Translate datatype Yes/No to text and add it to other text

A

acon

One of my fields has a datatype of Yes/No. How do I show text for this and
add this text to the beginning of another text field.
For example, Captain = Yes/No and attach this to Name
On the report it should show "Captain Smith" if it is Yes and "Smith" if it
is No.
 
L

Larry Linson

You've put "data in field names" which is not a good practice -- as in this
case, it often leads to complex code. It would be better to have a field
Title, one of the values of which could be "Captain".

With what you have, however, I believe you can do what you want with the
following expression as Control Source:

= IIF([Captain]=True,"Captain","") & PersonsName

Life gets more complicated if you have Yes/No fields for Lieutenant,
Colonel, and other ranks.

Larry Linson
Microsoft Access MVP
 
A

acon

If I did change it to values or just text, how would I combine these two
fields?

Larry Linson said:
You've put "data in field names" which is not a good practice -- as in this
case, it often leads to complex code. It would be better to have a field
Title, one of the values of which could be "Captain".

With what you have, however, I believe you can do what you want with the
following expression as Control Source:

= IIF([Captain]=True,"Captain","") & PersonsName

Life gets more complicated if you have Yes/No fields for Lieutenant,
Colonel, and other ranks.

Larry Linson
Microsoft Access MVP


acon said:
One of my fields has a datatype of Yes/No. How do I show text for this
and
add this text to the beginning of another text field.
For example, Captain = Yes/No and attach this to Name
On the report it should show "Captain Smith" if it is Yes and "Smith" if
it
is No.
 
D

Duane Hookom

Assuming your field name was [Title] then you would use an expression like:
=[Title] + " " & [PersonsName]

--
Duane Hookom
MS Access MVP


acon said:
If I did change it to values or just text, how would I combine these two
fields?

Larry Linson said:
You've put "data in field names" which is not a good practice -- as in
this
case, it often leads to complex code. It would be better to have a field
Title, one of the values of which could be "Captain".

With what you have, however, I believe you can do what you want with the
following expression as Control Source:

= IIF([Captain]=True,"Captain","") & PersonsName

Life gets more complicated if you have Yes/No fields for Lieutenant,
Colonel, and other ranks.

Larry Linson
Microsoft Access MVP


acon said:
One of my fields has a datatype of Yes/No. How do I show text for this
and
add this text to the beginning of another text field.
For example, Captain = Yes/No and attach this to Name
On the report it should show "Captain Smith" if it is Yes and "Smith"
if
it
is No.
 
Top