Public Dbcn As New adodb.Connection Public Rec As New adodb.Recordset AppPath = Trim(App.Path) + "\" Dbcn.Open "driver={Microsoft Access Driver(*.mdb)};Pwd=;dbq=" & AppPath & "db1.mdb" rec.open "select * from abc order by cba asc",dbcn,3,3set DBGrid.datasource=rec 'band recordset to the dbgrid control dbgrid.colums(0).caption="xxxx"
Below is to do that click a head of grid,sort automaticlyPrivate Sub DataGrid1_HeadClick(ByVal ColIndex As Integer) rsEmployees.Sort = rsEmployees.Fields(ColIndex).Name End Sub
Public Rec As New adodb.Recordset AppPath = Trim(App.Path) + "\"
Dbcn.Open "driver={Microsoft Access Driver(*.mdb)};Pwd=;dbq=" & AppPath & "db1.mdb"
rec.open "select * from abc order by cba asc",dbcn,3,3set DBGrid.datasource=rec 'band recordset to the dbgrid control
dbgrid.colums(0).caption="xxxx"
rsEmployees.Sort = rsEmployees.Fields(ColIndex).Name
End Sub