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

Strange results from DB query 1

Status
Not open for further replies.

canadatct

Programmer
Aug 11, 2003
26
0
0
CA
I am having a strange problem with a fairly simple query I am running on an Access DB. After running the query, I am populating a drop down list with the results. For some strange reason, when I loop through the results and insert each record into the <option> tags, it is skipping the very first record.

If I write the results from the query directly to the page, instead of populating the list, no problems at all. The first records shows up just fine.

Basically, if I query the database and only one result is being returned, I am presented with an empty drop down list.

Has anyone encountered this problem before? Am I missing something somewhere?!

Thanks in advance!
 
Without seeing your code it's a bit difficult to answer. Possibly use recordset.movefirst before you start populating your list?

Post your code and maybe we can help more.
 
I have been trying to use recordset.movefirst (which is actually included in this code), but it doesn't make any difference to my results.

rs.open strSQL, objConn,3,2,1

if rs.eof = true then
response.Write("<td class='cssError'>There are no results from your search. Please try again.")
else
rs.movefirst
response.Write("<td class='cssContent'>" & rs.recordcount & " result(s) listed below...<br><select class='cssContent' name='myList'")
While not rs.eof%>
<option value="<%response.Write(rs("ID"))%>"><%response.Write(rs("Desc"))%></option>
<%rs.movenext
wend
rs.close
set rs = nothing
end if %>
</select></td>
 
Select tag isn't closed:

...<select class='cssContent' name='myList'>
 
Thanks vongrunt........that did it.

It's funny how you can stare at something so long and miss the most obvious things!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top