Wrox Programmer Forums
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 26th, 2005, 04:00 PM
Registered User
 
Join Date: Aug 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to webmaster72
Default Dropdown Problem

I have a dropdown list populated with data from access database. It displays data in sequence order. However, I want it to display in reverse order, start with the latest entry. I have the code below:


<select name="ID">
<option></option>
<%
    ' Continue until we get to the end of the recordset.
    Do While Not objRS.EOF
        ' For each record we create a option tag and set it's value to the employee id
        ' The text we set to the employees first name combined with a space and then their last name
        %>
<option value="<%= objRS.Fields("ID") %>"><%= objRS.Fields("DDATE") %>/<%= objRS.Fields("DDATE1") %>/<%= objRS.Fields("DDATE2") %></option>
        <%
    ' Get next record
    objRS.MoveNext
    Loop
    %>
    </select>

Can anyone please tell me what do I need to change in the above code to make it display in reverse order? Thanks.
 
Old September 20th, 2005, 02:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Depending on how you open your recordset, objRs.Sort "ID Desc" might not work, so....
in the source of your recordset, state the sorting order.
eg:
Code:
Dim objRs
<%
Set objRs = Server.CreateObject("ADODB.RecordSet")
objRs.ActiveConnection = SomeConnectionString
objRs.CursorType = 3
objRs.LockType = 1
objRs.Source = "SELECT ID, DDATE, DDATE1, DDATE2 FROM YourTable ORDER BY ID DESC"
objRs.Open
If Not objRs.EOF Then
%>
<select name="ID">
<option></option>
<%
    ' Continue until we get to the end of the recordset.
    Do While Not objRS.EOF
        ' For each record we create a option tag and set it's value to the employee id
        ' The text we set to the employees first name combined with a space and then their last name
        %>
<option value="<%= objRS.Fields("ID") %>"><%= objRS.Fields("DDATE") %>/<%= objRS.Fields("DDATE1") %>/<%= objRS.Fields("DDATE2") %></option>
        <%
    ' Get next record
    objRS.MoveNext
    Loop
    %>
    </select>



I am a loud man with a very large hat. This means I am in charge





Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDown Value Selection problem....... dharmeshtandel ASP.NET 2.0 Basics 0 May 15th, 2008 07:27 AM
Dropdown Box problem migarich ASP.NET 1.0 and 1.1 Basics 3 March 22nd, 2006 10:28 AM
AJAX dropdown Problem savan_thakkar ASP.NET 2.0 Professional 0 February 7th, 2006 01:02 PM
Problem in dropdown list ankur_bhargava2000 ASP.NET 1.0 and 1.1 Basics 1 September 27th, 2005 09:29 AM
Problem with dropdown box Hlybbi C# 5 August 31st, 2004 04:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.