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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFIF statement help 3

Status
Not open for further replies.

kingjjx

Programmer
Sep 18, 2001
181
US
Hi, I have a table with a CODE field which could contain upto 5 different codes separated by commas

The field might have 0, 1 , 2 ,3 and upto 5 codes

How can I write a cfif statement to say that if code 1 is found , out put X, and if code 2 is found output Z and if code 3 is found out put W .. and so on ..

thank you

 
if all your codes are numeric (1,2,3...), you can try to use Find() instead of ListFind():

<cfif Find(1, Checkcode.codes)>
<img src=&quot;flag.gif&quot;>
</cfif>

<cfif Find(2, Checkcode.codes)>
<img src=&quot;flag.gif&quot;>
</cfif>

Sylvano
dsylvano@hotmail.com
 
Find() will work as long as you don't have more than ten codes. If you did, Find(1,qryCheckCodes.codes) would return a positive value if your list was '2,6,12' which is clearly not what kingjjx is going for.

I'm hoping to hear back from kingjjx soon about the debugging code I posted yesterday. I believe the ListFind() solution originally posted by GunJack is the right way to go -- we just need to work out some kinks. I think trimming the white space off the end of the string should solve the problem. Kingjjx?
 
ok, i think i see what you are trying to do (finally..)

Trim(qryCheckCodes.codes) will not do in this case;

use this instead to remove all the white spaces:

Remove(qryCheckCodes.codes, &quot; &quot;, &quot;&quot;, &quot;all&quot;) or

Remove(qryCheckCodes.codes, Chr(32), &quot;&quot;, &quot;all&quot;)


or use blank as second delimiter:

ListFind(qryCheckCodes.codes, &quot;1&quot;, &quot;,#Chr(32)#&quot;) Sylvano
dsylvano@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top