?
Solved

Sorting datagrids

Posted on 2003-03-13
5
Medium Priority
?
252 Views
Last Modified: 2010-05-01
Hi i am using datagrids in a vb front end to a sql database and the customer wants to be able to click on a column and sort the data by that column. Is there an easy way to do this or will have to do it by keep changing the SQL query behind the datagrid

Cheers
0
Comment
Question by:davoman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:happel
ID: 8127148
What type of datagrid are you using?
Many grids allow you to set a sort-property (or multiple sorts) at runtime.
0
 
LVL 1

Author Comment

by:davoman
ID: 8127187
hi it literally is the vb datagrid that is wat it is called
0
 
LVL 3

Accepted Solution

by:
happel earned 500 total points
ID: 8127280
Sorry, I can find any way of sorting this grid.
The VB help gives the following example:

Private Sub DataGrid1_HeadClick (ColIndex As Integer)
   Data1.RecordSource = "Select * From Publishers Order By " & _
    DataGrid1.Columns(ColIndex).DataField
   Data1.Refresh
End Sub

Very, very, very basic functionality...

0
 
LVL 11

Expert Comment

by:Steiner
ID: 8127698
If you don't want to use SQL each time you change sorting, you could use a recordset as source for your Datagrid.
Then just use:
MyRecordset.Sort = "name of field"
0
 
LVL 1

Author Comment

by:davoman
ID: 8233278
mite be basic but suits the needs of little old me.
Thanks for all the help
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question