Need to create a display message for when "No Results Found"

L

Lauren

Hello,

I searched on another forum for similar issues and found one, but since I'm
so new I think I need someone to help me with my specific code.

On a previous post I saw that they told them to use...

If Data1.Recordset.NoMatch = True Then MsgBox Text7.Text & " can not be
found in " & combo1.Text & ". Try searching a different field or check that
the data exists.", vbInformation, "Search Criteria Not Found"


I'm sure this is pretty much what I need, but I'm not sure where to put it
and exactly how I should modify the code to work for my page.

This is my page http://www.westar.com/careers/openings2.asp
Once you select a state then it would display the message "No Results
Found", if there are no job postings for the selected area.


Thanks,

Jackie
 
N

Nicholas Savalas - http://savalas.tv

Dear Lauren,
I went to your site http://www.westar.com/careers/openings2.asp, and
was looking for a job in Afghanistan. When I submitted my query, I was
taken to a page called Afghanistan.asp. I cannot see your code,
obviously, so I can't tell what is going on there. If you're using the
database results wizard, the page will submit to itself. The results
of your query will show on the same page that the query was made on.
The database results wizard will even give you an option of entering
exactly what terminology that you would like to use when no results are
found. Try creating a new connection to your database, make a new page
with the database results wizard, and test it. While I am not crazy
about wizards, in your case this may be just the thing you need. Good
luck, stay in touch.
 
L

Lauren

I am working from code that someone else developed and trying to make
enhancements.

Here is my code so maybe someone can tell me exactly what and where the
statement needs to go.


<%
strConn = "Provider=SQLOLEDB.1;Persist Security
Info=True;Password=is229002;User ID=webuser;Data Source=10.1.1.92;Initial
Catalog=Westar-Online"
set objConn = server.createobject("ADODB.Connection")
objConn.Open strConn

strSQL = "SELECT * FROM JobOpenings " & _
"WHERE (WorkLocation IN ('Corpus Christi','Ft. Hood','El Paso','Harker
Heights')) " & _
" AND ExternalyAvailable <> 'No' AND MarkAsDeleted <> 'Yes'" & _
"ORDER BY JobCode DESC"

set rsNewsItems = Server.CreateObject("ADODB.Recordset")
rsNewsItems.Source = strSQL
rsNewsItems.ActiveConnection = objConn
rsNewsItems.CursorType = adOpenForwardOnly
rsNewsItems.Open

%>
<html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Westar Aerospace &amp; Defense Group - A QinetiQ Company</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="style.css">
<style type="text/css" media="all">
<!--
@import url(main.css);
@import url(level_02.css);
-->
</style>

<script language="JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++)
x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<script language="javascript" type="text/javascript"
src="dmstatscript.js"></script>
<script>
DMPage();
</script>


</head>

<body>
<div id="pagewrapper">

<div id="logotop">
<a href="../index.asp" id="homelink" title="Westar Aerospace & Defense Group
- A QinetiQ Company Home Page">Home Page</a>
</div>

<div id="navtop"> <a href="../about/index.asp" id="link01" title="About
Westar">About
Westar</a> <a href="../capabilities/index.asp" id="link03" title="Westar
Capabilities">Capabilities</a>
<a href="../news/index.asp" id="link04" title="Westar News & Events">News
& Events</a> <a href="index.asp" id="link05" title="Careers at Westar"
class="active">Careers</a>
<a href="../contacts/index.asp" id="link06" title="Contact
Westar">Contacts</a>
</div>

<div id="breadcrumbs"><a href="../index.asp">Home</a> » <a
href="index.asp">Careers</a> » Current Openings
» Alabama</div>

<div id="contentmain">

<div id="activestage" style="width: 516px; height: 312px">

<h1 id="sectiontitle">Current Openings in Texas</h1>

</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" link="#333333"
onLoad=";Stats()" stats=1 vlink="#666666" alink="#CC0000">
<td height="157">
<table width="454" border="0" cellspacing="0" cellpadding="0" height="18">
<!--DWLayoutTable-->
<tr>
<td width="14"></td>
<td valign="top" class="bodycopy" width="412"> <table width="100%"
border="0" cellspacing="0" cellpadding="0">
<%
Dim rsUserSpec
Dim rsLocSpec
Dim LocName
While NOT rsNewsItems.EOF

strSQL4 = "SELECT OfficeName FROM Offices WHERE LocationName = '" &
rsNewsItems("WorkLocation") & "'"
set rsLocName = Server.CreateObject("ADODB.Recordset")
rsLocName.Source = strSQL4
rsLocName.ActiveConnection = objConn
rsLocName.CursorType = adOpenForwardOnly
rsLocName.Open


Response.Write("<tr>")

Response.Write("<td class=""bodycopy"" width=""79%""
valign=""top""><B>Position:</B> " & rsNewsItems("PositionTitle") & "<BR>")
Response.Write("<B>Location:</B> " & rsLocName("OfficeName") & "<BR>")
Response.Write("<B>Description:</B> " & rsNewsItems("PositionDescription") &
"<BR>")

Response.Write("<B>For more information:</B> <A HREF=jobcode.asp?id=" &
rsNewsItems("JobCode") & ">Click Here</A>" & "<BR>")
Response.Write("<img src=""../shim.gif"" width=""10"" height=""10""> </td>")
Response.Write("</tr>")
Response.Write("<tr bgcolor=""#666666"">")
Response.Write("<td class=""bodycopy"" width=""79%"" valign=""top""><img
src=""../shim.gif"" width=""1"" height=""1""></td>")
Response.Write("</tr>")
rsNewsItems.MoveNext
Wend


End If


set rsNewsItems = Nothing
set rsUserSpec = Nothing
set rsLocSpec = Nothing
objConn.Close
set objConn = Nothing



' <tr>
' <td class="bodycopy" width="79%" valign="top"><b><!--begin dynamic content
-->Position:</b>
' STRUCTURAL ENGINEER <br>
' <b>Location: </b>HEC <br>
' <b>Description: </b>Position requires recent experience
' in classical stress analysis, finite element analysis,
' design and analysis of aircraft structural modifications,
' structural loads analysis of aircraft, strength analysis
' of aircraft airframe, empennage, nacelle and land<br>
' <b>Referral #: </b>503<br>
' <b>Contact: </b>Send <a href="mailto:[email protected]">Rock
' Rhoades </a>an e-mail or call (256) 430-1610 <!--end dynamic content --><br>
' <img src="../shim.gif" width="10" height="10"> </td>
' </tr>
' <tr bgcolor="#666666">
' <td class="bodycopy" width="79%" valign="top"><img src="../shim.gif"
width="1" height="1"></td>
' </tr>

%>
<tr>
<td class="bodycopy" width="79%" valign="top">&nbsp;</td>
</tr>
</table></td>
<td height="18" width="28"></td>
</tr>
</table>

<!-- #include file="footer.html" -->
</body>
</html>


Thanks,

Lauren
 
N

Nicholas Savalas - http://savalas.tv

OK, um...room...spinning...Try this.......
Make a database entry in every city table for a 'position' that says
"No Results Found" - overwrite it when a first entry is made. o¿o !
I cant tell you where your if/else action should be because that is not
all the code at work here, I'm thinking of your solution, I cannot see
the whole problem.
But try my idiot answer first, I have others; like adding a column to
the db called showme - and edit the sql statement

"SELECT OfficeName FROM Offices WHERE LocationName = '" &
rsNewsItems("WorkLocation") & "'" ADD THIS--> and showme = 1......"

Get it? else :

Response.Write "No Results Found" or change the dummy "No Results
Found" entry to 0 in showme when populated with real jobs....

....that kind of thing. Keep us posted - good luck Lauren!
 
S

Stefan B Rusynko

Instead of using

While NOT rsNewsItems.EOF
........your code
Wend

Use

IF rsNewsItems.EOF Then
Response.write "No matching records Found"
ELSE
Do While NOT rsNewsItems.EOF
.......your code
Loop
END IF

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I am working from code that someone else developed and trying to make
| enhancements.
|
| Here is my code so maybe someone can tell me exactly what and where the
| statement needs to go.
|
|
| <%
| strConn = "Provider=SQLOLEDB.1;Persist Security
| Info=True;Password=is229002;User ID=webuser;Data Source=10.1.1.92;Initial
| Catalog=Westar-Online"
| set objConn = server.createobject("ADODB.Connection")
| objConn.Open strConn
|
| strSQL = "SELECT * FROM JobOpenings " & _
| "WHERE (WorkLocation IN ('Corpus Christi','Ft. Hood','El Paso','Harker
| Heights')) " & _
| " AND ExternalyAvailable <> 'No' AND MarkAsDeleted <> 'Yes'" & _
| "ORDER BY JobCode DESC"
|
| set rsNewsItems = Server.CreateObject("ADODB.Recordset")
| rsNewsItems.Source = strSQL
| rsNewsItems.ActiveConnection = objConn
| rsNewsItems.CursorType = adOpenForwardOnly
| rsNewsItems.Open
|
| %>
| <html>
| <?xml version="1.0" encoding="iso-8859-1"?>
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml">
|
| <head>
| <title>Westar Aerospace &amp; Defense Group - A QinetiQ Company</title>
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
| <link rel="stylesheet" href="style.css">
| <style type="text/css" media="all">
| <!--
| @import url(main.css);
| @import url(level_02.css);
| -->
| </style>
|
| <script language="JavaScript">
| <!--
| function MM_preloadImages() { //v3.0
| var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
| var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
| if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
| }
|
| function MM_swapImgRestore() { //v3.0
| var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++)
| x.src=x.oSrc;
| }
|
| function MM_findObj(n, d) { //v3.0
| var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
| d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
| if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
| x=d.forms[n];
| for(i=0;!x&&d.layers&&i<d.layers.length;i++)
| x=MM_findObj(n,d.layers.document); return x;
| }
|
| function MM_swapImage() { //v3.0
| var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
| for(i=0;i<(a.length-2);i+=3)
| if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
| x.oSrc=x.src; x.src=a[i+2];}
| }
| //-->
| </script>
| <script language="javascript" type="text/javascript"
| src="dmstatscript.js"></script>
| <script>
| DMPage();
| </script>
|
|
| </head>
|
| <body>
| <div id="pagewrapper">
|
| <div id="logotop">
| <a href="../index.asp" id="homelink" title="Westar Aerospace & Defense Group
| - A QinetiQ Company Home Page">Home Page</a>
| </div>
|
| <div id="navtop"> <a href="../about/index.asp" id="link01" title="About
| Westar">About
| Westar</a> <a href="../capabilities/index.asp" id="link03" title="Westar
| Capabilities">Capabilities</a>
| <a href="../news/index.asp" id="link04" title="Westar News & Events">News
| & Events</a> <a href="index.asp" id="link05" title="Careers at Westar"
| class="active">Careers</a>
| <a href="../contacts/index.asp" id="link06" title="Contact
| Westar">Contacts</a>
| </div>
|
| <div id="breadcrumbs"><a href="../index.asp">Home</a> » <a
| href="index.asp">Careers</a> » Current Openings
| » Alabama</div>
|
| <div id="contentmain">
|
| <div id="activestage" style="width: 516px; height: 312px">
|
| <h1 id="sectiontitle">Current Openings in Texas</h1>
|
| </head>
|
| <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" link="#333333"
| onLoad=";Stats()" stats=1 vlink="#666666" alink="#CC0000">
| <td height="157">
| <table width="454" border="0" cellspacing="0" cellpadding="0" height="18">
| <!--DWLayoutTable-->
| <tr>
| <td width="14"></td>
| <td valign="top" class="bodycopy" width="412"> <table width="100%"
| border="0" cellspacing="0" cellpadding="0">
| <%
| Dim rsUserSpec
| Dim rsLocSpec
| Dim LocName
| While NOT rsNewsItems.EOF
|
| strSQL4 = "SELECT OfficeName FROM Offices WHERE LocationName = '" &
| rsNewsItems("WorkLocation") & "'"
| set rsLocName = Server.CreateObject("ADODB.Recordset")
| rsLocName.Source = strSQL4
| rsLocName.ActiveConnection = objConn
| rsLocName.CursorType = adOpenForwardOnly
| rsLocName.Open
|
|
| Response.Write("<tr>")
|
| Response.Write("<td class=""bodycopy"" width=""79%""
| valign=""top""><B>Position:</B> " & rsNewsItems("PositionTitle") & "<BR>")
| Response.Write("<B>Location:</B> " & rsLocName("OfficeName") & "<BR>")
| Response.Write("<B>Description:</B> " & rsNewsItems("PositionDescription") &
| "<BR>")
|
| Response.Write("<B>For more information:</B> <A HREF=jobcode.asp?id=" &
| rsNewsItems("JobCode") & ">Click Here</A>" & "<BR>")
| Response.Write("<img src=""../shim.gif"" width=""10"" height=""10""> </td>")
| Response.Write("</tr>")
| Response.Write("<tr bgcolor=""#666666"">")
| Response.Write("<td class=""bodycopy"" width=""79%"" valign=""top""><img
| src=""../shim.gif"" width=""1"" height=""1""></td>")
| Response.Write("</tr>")
| rsNewsItems.MoveNext
| Wend
|
|
| End If
|
|
| set rsNewsItems = Nothing
| set rsUserSpec = Nothing
| set rsLocSpec = Nothing
| objConn.Close
| set objConn = Nothing
|
|
|
| ' <tr>
| ' <td class="bodycopy" width="79%" valign="top"><b><!--begin dynamic content
| -->Position:</b>
| ' STRUCTURAL ENGINEER <br>
| ' <b>Location: </b>HEC <br>
| ' <b>Description: </b>Position requires recent experience
| ' in classical stress analysis, finite element analysis,
| ' design and analysis of aircraft structural modifications,
| ' structural loads analysis of aircraft, strength analysis
| ' of aircraft airframe, empennage, nacelle and land<br>
| ' <b>Referral #: </b>503<br>
| ' <b>Contact: </b>Send <a href="mailto:[email protected]">Rock
| ' Rhoades </a>an e-mail or call (256) 430-1610 <!--end dynamic content --><br>
| ' <img src="../shim.gif" width="10" height="10"> </td>
| ' </tr>
| ' <tr bgcolor="#666666">
| ' <td class="bodycopy" width="79%" valign="top"><img src="../shim.gif"
| width="1" height="1"></td>
| ' </tr>
|
| %>
| <tr>
| <td class="bodycopy" width="79%" valign="top">&nbsp;</td>
| </tr>
| </table></td>
| <td height="18" width="28"></td>
| </tr>
| </table>
|
| <!-- #include file="footer.html" -->
| </body>
| </html>
|
|
| Thanks,
|
| Lauren
|
| "Nicholas Savalas - http://savalas.tv" wrote:
|
| > Dear Lauren,
| > I went to your site http://www.westar.com/careers/openings2.asp, and
| > was looking for a job in Afghanistan. When I submitted my query, I was
| > taken to a page called Afghanistan.asp. I cannot see your code,
| > obviously, so I can't tell what is going on there. If you're using the
| > database results wizard, the page will submit to itself. The results
| > of your query will show on the same page that the query was made on.
| > The database results wizard will even give you an option of entering
| > exactly what terminology that you would like to use when no results are
| > found. Try creating a new connection to your database, make a new page
| > with the database results wizard, and test it. While I am not crazy
| > about wizards, in your case this may be just the thing you need. Good
| > luck, stay in touch.
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top