Print Page | Close Window

If Then Else statement

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5628
Printed Date: 31 March 2026 at 6:30am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: If Then Else statement
Posted By: kenn
Subject: If Then Else statement
Date Posted: 09 September 2003 at 1:11pm

I have a page which displays people who have registered for a particular tender. Which works fine however some tenders have no one registered. Can anyone tell me how i use an IF THEN ELSE Statement ??? to display  a message like 'No one has registered for this tender' if the fields are blank.

Below is the code on the page.

Many thanks

Kenn

<TABLE width="30%" align="center" border="0" cellPadding="2" cellSpacing="0">
<TR>
<TD WIDTH="30%" class="text"><center><%=Session("currentTender")%>&nbsp
;Registrations:<center></TD>
</TR>
</TABLE>
<br>
<TABLE bgcolor="<% = strTableBorderColour %>" WIDTH="75%" ALIGN="center" BORDER="1" CELLPADDING="2" CELLSPACING="0">
<TR ALIGN="center" bgcolor="<% = strTableBorderColour %>">
<TD><center><font face="arial" color="#000000" size="3">First Name</font><center></TD>

<TD><center><font face="arial" color="#000000" size="3">Last Name</font><center></TD>

<TD><center><font face="arial" color="#000000" size="3">Company</font><center></TD>
<TD><center><font face="arial" color="#000000" size="3">Position</font><center></TD>
<TD><center><font face="arial" color="#000000" size="3">Email</font><center></TD>
<TD><center><font face="arial" color="#000000" size="3">Tender</font><center></TD>
</TR>
<%
Dim objLot, SQL, oRS, oConn, SQLstmt
Set conn = server.createobject("adodb.connection")
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("../private/zips.mdb")
conn.Open DSNtemp
SQL = "Select regID, FirstName, LastName, Company, Position, Email, Download From registrations WHERE DownLoad='" & Session("currentTender") & "'"
Set oRS = conn.Execute(SQL)
While Not oRS.EOF
%>
<TR ALIGN="center" bgcolor="<% = strTableBorderColour %>">
<TD><input type="text" name="FirstName" size="12" value="<%=oRS("FirstName")%>"</TD
>
<TD><input type="text" name="LastName" size="12" value="<%=oRS("LastName")%>"</TD
>
<TD><input type="text" name="Company" size="28" value="<%=oRS("Company")%>"</TD
>
<TD><input type="text" name="Position" size="18" value="<%=oRS("Position")%>"</TD
>
<TD><input type="text" name="Email" size="30" value="<%=oRS("Email")%>"</TD
>
<TD><input type="text" name="Download" size="25" value="<%=oRS("Download")%>"</TD
>
</TR>

<%
oRS.MoveNext
Wend
conn.Close
Set conn = nothing
Set SQLstmt = nothing
End If


-------------
ken at newhall




Replies:
Posted By: michael
Date Posted: 09 September 2003 at 1:34pm

Assuming that download = tender


<TD><input type="text" name="Download" size="25" value="<%=oRS("Download")%>"</TD>

to

<% mystring = oRS("Download")
      If mystring = "" THEN mystring = "No one has registered for this tender"
%>
<TD><input type="text" name="Download" size="25" value="<%=mystring%>"</TD>       

I hope I understood you right. Not sure if that is what you are after.



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: 3BEPb
Date Posted: 09 September 2003 at 10:50pm

OR:

Set oRS = conn.Execute(SQL)
If oRS.RecordCount=0 Then
    response.write "No one has registered for this tender"
Else

While Not oRS.EOF
%>
<TR ALIGN="center" bgcolor="<% = strTableBorderColour %>">

<TD><input type="text" name="FirstName" size="12" value="<%=oRS("FirstName")%>"</TD
>
<TD><input type="text" name="LastName" size="12" value="<%=oRS("LastName")%>"</TD
>
<TD><input type="text" name="Company" size="28" value="<%=oRS("Company")%>"</TD
>
<TD><input type="text" name="Position" size="18" value="<%=oRS("Position")%>"</TD
>
<TD><input type="text" name="Email" size="30" value="<%=oRS("Email")%>"</TD
>
<TD><input type="text" name="Download" size="25" value="<%=oRS("Download")%>"</TD
>
</TR>

<%
oRS.MoveNext
Wend
End If



Posted By: michael
Date Posted: 10 September 2003 at 7:33am
Yeah, I am not sure if he was looking for empty table or record in a certain field.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net