PDA

Click to See Complete Forum and Search --> : SQL and VB


skooby
Nov 2nd, 2000, 03:57 PM
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

Bigley
Nov 2nd, 2000, 04:26 PM
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.

skooby
Nov 6th, 2000, 10:45 AM
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