My code was working fine when I was using just one of the below pieces of code but when I added another one, the results for it did not show up. It seems EOF can’t work when its run twice on the same page. If anyone can help, that would be appreciated.
<% while (NOT con.EOF) %>
CODE HERE
<%con.MoveNext()
Wend %>
CODE:
<% if not con.BOF then %>
<div style="margin-top:1em">
<form action="dbresults.htm" method="get">
<p>Company name:<br/>
<select name="abn">
<option label="All companies" value="all"></option>
<% while (NOT con.EOF) %>
<option label="<%=con("legal")%>" value="<%=con("abn")%>"></option>
<%con.MoveNext()
Wend %>
</select>
</p>
<p>Categories for Creative Design:<br/>
<select name="cat">
<option label="All categories" value="all"></option>
<option label="Strategic brand, marketing and communications advice" value="a"></option>
<option label="Graphic design and layout" value="b"></option>
<option label="Forms design" value="c"></option>
<option label="Web design and development" value="d"></option>
<option label="Authoring services" value="e"></option>
<option label="Editorial services" value="f"></option>
<option label="Translation services" value="g"></option>
<option label="Photography and film services" value="h"></option>
<option label="Scanning and digitisation services" value="i"></option>
<option label="Multimedia editing services" value="j"></option>
</select>
</p>
<input type="submit" value="Search" />
</form>
<br /><hr />
<table style="font-size:.9em;" class="contentTable">
<tr>
<th>ABN:</th>
<th>Company Name:</td>
</tr>
<% while (NOT con.EOF) %>
<tr>
<td><%=con("abn")%></th>
<td><a href="dbcomp.htm?abn=<%=con("abn")%>&cat=all">
<%=con("legal")%></a></td>
</tr>
<%
con.MoveNext()
Wend
%>
</table>
</div>
<% else %>
<p>No records match your query.</p>
<p><a href="dbtest.htm">Return to search page</a></p>
<%
end if
con.close
%>
After your first WHILE loop (
while (NOT con.EOF)) your recordset is left at EOF, therefore your second loop won’t do anything. You need to reposition the cursor in your recordset prior to your second loop. Usecon.MoveFirst(),con.MovePrevious(), etc to reposition.