Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - If then in ASP
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

If then in ASP

 Post Reply Post Reply Page  12>
Author
PaulGQ View Drop Down
Newbie
Newbie
Avatar

Joined: 11 June 2003
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote PaulGQ Quote  Post ReplyReply Direct Link To This Post Topic: If then in ASP
    Posted: 11 June 2003 at 4:21pm

I have an asp query pulling data from an access database.

What I need to do is display the data as follows

if value="ABC" then display it as "XYZ"

if value="DEF" then display it as "TUV"

I'd like to do this in the query in access and then just have my asp script point to the query for the data, or I can reformat the data in the asp script with i guess with something like the following:

<% if (rs.Fields("Customer").Value)= "ABC" then %>XYZ <% else =(rs.Fields("Customer").Value)%>

<% if (rs.Fields("Customer").Value)= "DEF" then %>TUV <% else =(rs.Fields("Customer").Value)%>

But this doesnt seem to work as I get an an unexpected next message or syntax error.

Any help is appreciated. 

 

 

 

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2003 at 4:32pm

<% if (rs.Fields("Customer").Value)= "ABC" then%>
XYZ
<% else

response.write(rs.Fields("Customer").Value)

end if%>

Back to Top
PaulGQ View Drop Down
Newbie
Newbie
Avatar

Joined: 11 June 2003
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote PaulGQ Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2003 at 4:46pm

That works great for the ABC, but what about the DEF?

 

and GHI if we need to add it in down the road

Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2003 at 4:50pm

Or you could use:-

<% 
If (rs.Fields("Customer").Value)= "ABC" then Response.Write("XYZ") else Response.Write(rs.Fields("Customer").Value)

if (rs.Fields("Customer").Value)= "DEF" then Response.Write("TUV") else Response.Write(rs.Fields("Customer").Value)
%>



Edited by -boRg-
Back to Top
PaulGQ View Drop Down
Newbie
Newbie
Avatar

Joined: 11 June 2003
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote PaulGQ Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2003 at 5:00pm

boRg,

that returns "XYZDEF"



Edited by PaulGQ
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2003 at 5:13pm
Place a vbCrLF of <br> or " " inbwteen the results so that they are not all together then.
Back to Top
PaulGQ View Drop Down
Newbie
Newbie
Avatar

Joined: 11 June 2003
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote PaulGQ Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2003 at 6:09pm

INneed the results either one or the other, not both put together.

If I am misunderstanding you, can you please write out what you mean exactly?

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2003 at 7:20pm

<%
If (rs.Fields("Customer").Value)= "ABC" then Response.Write("XYZ")
ELSEIf (rs.Fields("Customer").Value)= "DEF" then Response.Write("TUV")
else Response.Write(rs.Fields("Customer").Value)
%>

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.