VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



DBGrid Sort

by Adam Abas (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (9 Votes)

It is nice technique for dbgrid sorting.You
can sort Dbgrid Columns by clicking on the grid column header
in two ways ascending or descending.

Code Returns
Sorted Records in dbgrid.
Side Effects
No Idea,
API Declarations

Rate DBGrid Sort

Option Explicit
Dim st As Boolean
***********************
Private Sub DBGrid1_HeadClick(ByVal ColIndex As Integer)
'Dbgrid Columns sort by clicking the grid header in two way ascending and descending
 If st = True Then
 DBGrid1.HoldFields
 Data1.RecordSource = " Select * from Authors Order By " & DBGrid1.Columns(ColIndex).DataField
 Data1.Refresh
 DBGrid1.ReBind
 Else
 DBGrid1.HoldFields
 Data1.RecordSource = " Select * from Authors Order By " & DBGrid1.Columns(ColIndex).DataField & " DESC "
 Data1.Refresh
 DBGrid1.ReBind
 End If
 st = Not st
End Sub

Download this snippet    Add to My Saved Code

DBGrid Sort Comments

No comments have been posted about DBGrid Sort. Why not be the first to post a comment about DBGrid Sort.

Post your comment

Subject:
Message:
0/1000 characters