ACC2000: How to Set Multiple Sort Order Values on a Data Access PageID: Q234986
|
This article shows you how to create an HTML page that sorts a data access page by three different fields. This HTML page is a frameset made up of two data access pages. The first page provides the controls to sort the second page.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.aspThis article show how to create an HTML page (Frameset Page) and two data access pages (Header Page and Detail Page) in the sample database Northwind.mdb.
Table: tblSort
-------------------
Field Name: SortFld
Data Type: Text
Table Properties: tblSort
-------------------------
PrimaryKey: SortFld
City
CompanyName
ContactName
Country
CustomerID
Region
Command button
--------------
ID: cmdSort
Caption: Sort
Command button
--------------
ID: cmdClear
Caption: Clear
Dropdown list
-----------------------------
ID: SortList1
ListRowSource: Table: tblSort
ListDisplayField: SortFld
ListBoundField: SortFld
Dropdown list
------------------------------
ID: SortList2
ListRowSource: Table: tblSort
ListDisplayField: SortFld
ListBoundField: SortFld
Dropdown list
------------------------------
ID: SortList3
ListRowSource: Table: tblSort
ListDisplayField: SortFld
ListBoundField: SortFld
Option group
------------------------------
ID: Frame1
BorderStyle: none
Set the group legend's Visibility property to hidden.
Option button (inside Frame1)
------------------------------
ID: OptionAsc1
Set the InnerText property of the button's Label to Ascending.
Option button (inside Frame1)
------------------------------
ID: OptionDsc1
Set the InnerText property of the button's Label to Descending.
Option group
------------------------------
ID: Frame2
BorderStyle: none
Set the group legend's Visibility property to hidden.
Option button (inside Frame2)
------------------------------
ID: OptionAsc2
Set the InnerText property of the button's Label to Ascending.
Option button (inside Frame2)
------------------------------
ID: OptionDsc2
Set the InnerText property of the button's Label to Descending.
Option group
------------------------------
ID: Frame3
BorderStyle: none
Set the group legend's Visibility property to hidden.
Option button (inside Frame3)
------------------------------
ID: OptionAsc3
Set the InnerText property of the button's Label to Ascending.
Option button (inside Frame3)
------------------------------
ID: OptionDsc3
Set the InnerText property of the button's Label to Descending.
<SCRIPT language=vbscript>
<!--
Public strSort
-->
</SCRIPT>
<SCRIPT event=onclick for=cmdSort language=vbscript>
<!--
Dim i
strSort = ""
For i = 1 to 3
' Determine which dropdown lists contain field names.
If Document.All.Item("sortList" & i).Value <> "" Then
' Add the field names to the sort order sting.
strSort = strSort & Document.All.Item("sortList" & i).Value
If Document.All.Item("OptionDsc" & i).Checked = True Then
' Add the word "Desc" (to sort the field in descending order)
' and a list separator to the sort string.
strSort = strSort & " Desc, "
Else
' Add a list separator to the sort string. It will automatically
' sort the field in ascending order, however, you could include
' then word "Asc".
strSort = strSort & ", "
End if
End if
Next
' Remove the extra characters from the end of the sort string
If Right(strSort, 2) = ", " Then
strSort=Left(strSort, Len(strSort)-2)
End if
' Set the sort order for the Detail page.
Window.Parent.Frames("dtl").MSODSC.DataPages(0).Recordset.Sort=strSort
-->
</SCRIPT>
<SCRIPT event=onclick for=cmdClear language=vbscript>
<!--
' Reset all the dropdown lists and option buttons.
For i = 1 to 3
Document.All.Item("SortList" & i).Value = ""
Document.All.Item("OptionAsc" & i).Checked = False
Document.All.Item("OptionDsc" & i).Checked = False
Next
' Clear the sort string
strSort = ""
' Set the sort order for the Detail page back to the default.
Window.Parent.Frames("dtl").MSODSC.DataPages(0).Recordset.Sort=strSort
-->
</SCRIPT>
Text box
-------------------------
ID: CustomerID
ControlSource: CustomerID
Text box
--------------------------
ID: CompanyName
ControlSource: CompanyName
Text box
--------------------------
ID: ContactName
ControlSource: ContactName
Text box
-------------------
ID: City
ControlSource: City
Text box
----------------------
ID: Country
ControlSource: Country
Text box
---------------------
ID: Region
ControlSource: Region
<HTML>
<FRAMESET ROWS="18%, *">
<FRAME ID="hdr" SRC="dapSortHeader.htm">
<FRAME ID="dtl" SRC="dapSortDetail.htm">
</FRAMESET>
</HTML>
Additional query words: sorted sorting
Keywords : kbdta AccCon AccDAP DAPScriptHowTo dtavbscript
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: August 9, 1999