Adrienne
I tried your example and it clears out my values. I need to repass my
values back to the server (I think). The value of "sort" works when the
page loads. For example I change the "else" to "Code" and it sorts by Code,
but the default I want is State.
This is what I have it seems to be losing the values of "rState, insName,
and occFilt"
dim sort
sort = request.QueryString("sort")
select case sort
case 1
sort = " ORDER BY State "
case 2
sort = " ORDER BY Code "
case 3
sort = " ORDER BY Occupation "
case 4
sort = " ORDER by PolicyNumber "
case else
sort = " ORDER by State "
end select
rState = Request.QueryString("state")
insName = Request.QueryString("ins")
occFilt = Request.QueryString("fo")
table border="0" align="center" bgcolor="#990033">
<tr>
<td align=center width=50><font color=white size=2 face="Tahoma"><b><a
href="<%=request.servervariables("script_name")%>? sort=1">State</a></b></td>
<td align=center width=80><font color=white size=2 face="Tahoma"><b><a
href="<%=request.servervariables("script_name")%>? sort=2">Code</a></b></td>
<td align=center width=250><font color=white size=2
face="Tahoma"><b>Occupation</a></b></td>
<td align=center width=100><font color=white size=2 face="Tahoma"><b>Policy
Number</a></b></td>
<td align=center width=80><font color=white size=2
face="Tahoma"><b>Effective Date</b></td>
<td align=center width=80><font color=white size=2
face="Tahoma"><b>Expiration Date</b></td>
</tr>
</table>
Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("ncci.mdb")
Conn.Open DSNtest
Set rs2 = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM NCCI2 where Insured = " & sIn(insName) & sort
rs2.Open strSQL, conn, 3, 3
if not rs2.eof then
nr = rs2.recordcount
for i = 1 to nr
%>
<table align="center">
<tr bgcolor="#f6f0e3">
<td align=center width=50><font size=2 face="Tahoma"><% = rs2("State")
%></td>
<td align=center width=80><font size=2 face="Tahoma"><% = rs2("Code")
%></td>
<td align=center width=250><font size=2 face="Tahoma"><% =
rs2("Occupation") %></td>
<td align=center width=100><font size=2 face="Tahoma"><% =
rs2("PolicyNumber") %></td>
<td align=center width=80><font size=2 face="Tahoma"><% =
rs2("PolicyEffective") %></td>
<td align=center width=80><font size=2 face="Tahoma"><% =
rs2("PolicyExpiration") %></td>
</tr>
<tr>
</table>
Please advise
"Adrienne" <ar********@sbcglobal.net> wrote in message
news:Xn****************************@207.115.63.158 ...
Gazing into my crystal ball I observed "SASRS" <mc******@srs.com> writing
in news:uH**************@tk2msftngp13.phx.gbl:
"SASRS" <mc******@srs.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl... Sorting it on the client side
"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:Og**************@TK2MSFTNGP10.phx.gbl...
> SASRS wrote:
> > FieldA = Request.QueryString("A")
> > FieldB = Request.QueryString("B")
> > FieldC = Request.QueryString("C")
> > ...
> > I would like to make the header row sortable by clicking on
> > the field name. I have tried use A HREF and passing a variable
> > called sort, but it doesn't seem to work. Any help is much
> > appreciated.
>
> Are you asking how to (a) conditionally ask the DB to sort, (b) sort
> the data on the server once you get it back from the database, or
> (c) sort it on the client side? Each requires a different approach.
>
>
>
It is actually server-side, not client side, but client-side might work
for me.
This is what I have so far, I am trying to re-pass the values back to
the page.
<a
href="http://s2.asp?sort=1?FieldA=<%=FieldA%>?FieldB=<%=FieldB% >?FieldC=
<%=F ieldC%>">
I see the values when I hover over the link, but when i hit the link,
my results are blank. I believe I am overwriting the values below.
How can I work around that.
FieldA = Request.QueryString("A")
FieldB = Request.QueryString("B")
FieldC = Request.QueryString("C")
Here's what I do:
dim sort
sort = request.querystring("sort")
select case sort
case 1
sort = " ORDER BY field "
case 2
sort = " ORDER BY anotherfield "
case else
sort = " ORDER by field "
end select
sql = "SELECT records FROM table WHERE clause " & sort
Set rs = CreateObject("ADODB.Recordset")
rs.Open sql, connectionstring
if rs.EOF then
%>
<p>No records found</p>
<% else %>
<table summary="List of records">
<caption>List of Records</caption>
<thead>
<tr>
<th><a href="<%=request.servervariables("script_name")%>? sort=1">Field</a>
</th>
<th><a href="<%=request.servervariables("script_name")%>? sort=2">Another
Field</a></th>
</tr>
</thead>
<tbody>
<%
while not rs.EOF
field = trim(rs("field")
anotherfield = trim(rs("anotherfield"))
%>
<tr>
<td><%=field%></td><td><%=anotherfield%></td>
</tr>
<% rs.MoveNext
wend
rs.Close
set rs = nothing
set connectionstring = nothing
%>
</tbody>
</table>
<% end if%>
FYI, the TH element usually centers and bolds the content, so no need for
the depreciated B element. You might want to remove your presentational
markup and replace it with CSS, makes debugging so much easier.
--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share