Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String output based on Integer

Status
Not open for further replies.

R34LiSM

Programmer
May 16, 2002
10
GB
I'm trying to get an Access 97 report to display a text string for each integer entered in the source table. Here's the pseudo-code for what I'm trying to achieve;

If table.class=1 Then report.class="Monitor"
Else If table.class=2 Then report.class="Grave"
Else If table.class=3 Then report.class="Critical"
End If

I simply cannot get this to work. Can someone, anyone please help me with this?!? [sad]
 
If I follow you correctly, for each field that has a numerical value, you're wanting to replace it with a text string.

Man, was I beating myself over the head on this one a few times until I finally hacked it out myself. Here's the code that you would want to put into the field expression:

IIf([FieldToEval]=1,"TextFor1",IIf([ContactMethod]=2,"TextFor2"))

If you have several field checks, you'll need to nest the IF statement everytime to remember that the IF statement is formatted as such:

IIF(CriteriaToEvaluate, RunIfTrue, RunIfFalse)

Enjoy!
Roy
aka BanditWk
Las Vegas, NV
roy@cccamerica.org
RLMBandit@aol.com (private)
 
An easier approach for the simple selection:

Code:
MyX = 2
? Choose(MyX, "Text1", "Text2", "Text3")
Text2

Of course you need to look at the help / syntax for the choose method. For one thing, you can get garbage results if the selection is not in the list.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top