changing text dynamicaly in a report

  • Thread starter Thread starter CShow
  • Start date Start date
C

CShow

I have a label on my report called "Status" I want the report label to read
"Bad" if the Company is "Acme Store" or "Acme Industries". Or "Good" if
another company. How do I accomplished this. So far I've used the IFF and IF
statements to no avail. I need something like this pseudo code:

If (Company like "%Acme%", "Bad", "Good")

And How would I nest these IF statements if I want another company like
"Truen Store" or "Truen Industries" to be labeled as 'Bad"

Thank you
 
You can't use any function in a label caption. You can use a text box with a
control source like:
=IIf(Left([Company],4)="Acme", "Bad", "Good")
I would actually recommend that you store some value in a table rather than
"hard-coding" expressions like this.
 
Thanks, Duane. That works!
Duane Hookom said:
You can't use any function in a label caption. You can use a text box with a
control source like:
=IIf(Left([Company],4)="Acme", "Bad", "Good")
I would actually recommend that you store some value in a table rather than
"hard-coding" expressions like this.

--
Duane Hookom
MS Access MVP


CShow said:
I have a label on my report called "Status" I want the report label to read
"Bad" if the Company is "Acme Store" or "Acme Industries". Or "Good" if
another company. How do I accomplished this. So far I've used the IFF
and
IF
statements to no avail. I need something like this pseudo code:

If (Company like "%Acme%", "Bad", "Good")

And How would I nest these IF statements if I want another company like
"Truen Store" or "Truen Industries" to be labeled as 'Bad"

Thank you
 
It works, but you missed the point of Duanes reply.
What do you intend to do when you get additional companies which need to be
labeled as 'Bad', or when a completely different good company, named perhaps
'ACMedical Supplies', is incorrectly labeled as 'Bad'?

Make a table to contain the list of all 'Bad' companies.
Then use a DLookUp in a text control to check if the exact company name is
in the table:
=IIf(DLookUp("[BadCompany]","BadCompanyTable","[BadCompany] = " & chr(34) &
[Company] & chr(34)),"Bad","Good")

Add new companies to the table as needed. No need to constantly change the
code.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


CShow said:
Thanks, Duane. That works!
Duane Hookom said:
You can't use any function in a label caption. You can use a text box
with
a
control source like:
=IIf(Left([Company],4)="Acme", "Bad", "Good")
I would actually recommend that you store some value in a table rather than
"hard-coding" expressions like this.

--
Duane Hookom
MS Access MVP


CShow said:
I have a label on my report called "Status" I want the report label
to
read
"Bad" if the Company is "Acme Store" or "Acme Industries". Or "Good" if
another company. How do I accomplished this. So far I've used the IFF
and
IF
statements to no avail. I need something like this pseudo code:

If (Company like "%Acme%", "Bad", "Good")

And How would I nest these IF statements if I want another company like
"Truen Store" or "Truen Industries" to be labeled as 'Bad"

Thank you
 
I suggest you add a field to the table. Name the field
something like Status. Default is G (for Good). Put a
control on your form so you can change it to Bad whenever
you want. You can use a toggle button, or two option
buttons grouped together. In your report, create the
control that displays "Good" if the value is -1 and "Bad"
if its value is 0. (Assuming you assign 0 to bad and -1
to good. You could always use 1 for good and 2 for bad...
whatever). Put your code in the OnFormat event of the
Form. There are many other ways of dealing with this.
 
Dan,
That's actually what I did after reading Duane statement. You guys are a
great resource. Thanks
 
Back
Top