General discussion
December 3, 2002 at 07:30 AM
tsaurman

Help with Datagrid and Stand-Alone Data

by tsaurman . Updated 23 years, 9 months ago

I have a question/problem. I am using a Datagrid in VB and populating the grid with on-the-fly Stand-Alone data. When I use a ‘recordset.sort’ this grid sort fine except that the sorting is done on the first character. So all of the 1’s get sorted together with all of the 10’s and 100’….

Her is the VB Code that I am using:
Dim rsQuota As New ADODB.Recordset
rsQuota.Fields.Append “Usage”, adChar, 25, adFldIsNullable
rsQuota.Open
‘Add New Record into the DataGrid
rsQuota.AddNew
‘AddNew Items into the UserQuota
rsQuota(“Usage”) = QuotaUsage
rsQuota.Update
Set DataGridQuota.DataSource = rsQuota

Private Sub DataGridQuota_HeadClick(ByVal ColIndex As Integer)
‘ Sort on the clicked column
If rsQuota.Sort <> DataGridQuota.Columns(ColIndex).DataField & ” ASC” Then
rsQuota.Sort = DataGridQuota.Columns(ColIndex).DataField & ” ASC”
Else
rsQuota.Sort = DataGridQuota.Columns(ColIndex).DataField & ” DESC”
End If
End Sub

I would like to use the code listed below, but since I am not connecting to a Database I am have problems formatting the Select statement:
[I am not sure what to use for the ‘From Table_Name’ since I am not connecting to a table.]

Dim SQL
SQL = “Select * From ‘Table_Name'”
rsQuota.Close
rsQuota.Source = SQL & ” Order By ” & DataGridQuota.Columns(ColIndex).DataField
rsQuota.Open
Set DataGridQuota.DataSource = rsQuota

Any help would be appreciated.

Thomas

This discussion is locked

All Comments