Implementation
The procedure may sound complicated but it isn't.
You'll need three things;
- an ASP script to calculate the 'Order By' clause
(below)
- a custom DRW query that uses the 'Order By'
clause.
- a button or hyperlink that executes the query.
ASP ScriptPlace this above the <html> tag
on your query page; <%
const orderBy_default = ""
const orderBy_field = "orderby"
const orderBy_form = "search"
function orderBy(field)
dim order, fields
order = request(orderBy_field)
If order = "" Then order = orderBy_default
fields = split(order, ",", -1)
if fields(0) = field OR fields(0) = field & " asc" then
fields(0) = field & " desc"
elseif fields(0) = field & " desc" Then
fields(0) = field
else
fields(0) = field & "," & fields(0)
end if
orderBy = "document." & orderBy_form & "." & orderBy_field & ".value ='" & join(fields, ",") & "';document." & orderBy_form & ".submit();void(0);"
end function
%>
<html> |
DRW Custom QueryCreate a custom DRW query with
an order by clause. In the example below, ::orderby:: is replaced by a
database field name and a sort order (asc or desc) when
the query is run.
SELECT * FROM Table Order By
::orderby::"
Set a default value in the DRW for the orderby clause. For example;
LastName asc
Modify the 1st line of the ASP script (orderBy_default) to match your default orderby clause. For example:
const orderBy_default = "id asc" NOTE: If an MS-Access database field name has spaces (e.g. Last Name), always enclose the field name in brackets (e.g. [Last Name]) |