Creatable RecordSet and MSHFlexGrid
Hi all,
I am using the creatable recordset method for creating a recordset, and it is working fine. Then I did fetch the recordset to a MSHFlexGrid. The problem is I am not getting the exapndable (+) and Collapsing (-) signs.
Here is the code
Private Sub Form_Load()
'Sub CreatableRst_Files(strPath As String)
'This is an example of creating a recordset
'from non-relational data
'Creates a recordset of file names and extensions
Dim StrPath As String
StrPath = "E:\"
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
With rst 'Do local work
.CursorLocation = adUseClient
'Add a field here
.Fields.Append "Extension", adVarChar, 255, adFldLong
.Fields.Append "FileName", adVarChar, 255, adFldLong
.Fields.Append "RowId", adVarChar, 255, adFldRowID
'Open the rst
.Open , , adOpenStatic, adLockBatchOptimistic 'Make sure there is an \ in the path
If Right(StrPath, 1) <> "\" Then _
StrPath = StrPath & "\" 'Get a list of all files in the DIR and then
'add them to the recordset
StrPath = Dir(StrPath & "*.*", vbNormal)
' Don't include the . and .. entries
Do While StrPath > ""
'Add the record to the rst here
.AddNew Array("Extension", "FileName", "RowId"), Array(Right(StrPath, 3), StrPath, StrPath)
StrPath = Dir
Loop
.MoveFirst
'Print out the files
'You can also return a recordset as a function return value to work with the recordset in another procedure
Do Until .EOF
'Debug.Print !FileName
'Debug.Print !Extension
rst.MoveNext
Loop
Debug.Print rst.RecordCount
End With
Set MSHFlexGrid1.DataSource = rst '.DataSource
MSHFlexGrid1.AllowUserResizing = flexResizeBoth
End Sub