I am wanting to allow the user to click Sort Ascending or Sort Descending and have a datagrid sort by name accordingly. How can this be done w/ SQL or is there an easier way to do this?
Thanks
Printable View
I am wanting to allow the user to click Sort Ascending or Sort Descending and have a datagrid sort by name accordingly. How can this be done w/ SQL or is there an easier way to do this?
Thanks
At the end of your SQL statement use the ORDER BY clause and select the field you wish to order by eg.
Select * from Customers
Order By LastName
You can also specify Asc/Desc dependiong on which you want, default is Asc.
Here is a sample of the code I am using.....Right now I have menu as follows....
Sort
Sort Asc
Sort Desc
But when I click these nothing happens
Here is the code in the Sort Desc routine
cDbase = "C:\PhoneDirectory.mdb"
cTable = "Directory"
cSort = " ORDER BY "
cField = ""
cSelect = "SELECT * FROM "
cTry = "SORT DESC"
Adodc1.RecordSource = cSelect + cTable + cSort + "Name"
DataGrid1.Refresh
Any suggestions?
Thanks