Mega Code Archive

 
Categories / VisualBasic Script / Access
 

Creating a Custom Recordset

Sub Custom_Recordset()     Dim myRecordset As ADODB.Recordset     Dim strFile As String     Dim strFolder As String     strFolder = "C:\"     strFile = Dir(strPath & "*.*")     Set myRecordset = New ADODB.Recordset     With myRecordset        Set .ActiveConnection = Nothing            .CursorLocation = adUseClient            With .Fields                      .Append "Name", adVarChar, 255                      .Append "Size", adDouble                      .Append "Modified", adDBTimeStamp            End With             .Open               ' Add a new record to the recordset               .AddNew Array("Name", "Size", "Modified"), _                Array("fileName.txt", 100, #9/9/1999#)             .MoveFirst              ' Print the contents of the recordset to the Immediate window                  Do Until .EOF                       Debug.Print !Name & vbTab & !Size & vbTab & !Modified                      .MoveNext                  Loop                  .Close          End With      Set myRecordset = Nothing End Sub