Jon von der Heyden
MrExcel MVP, Moderator
- Joined
- Apr 6, 2004
- Messages
- 10,907
- Office Version
- 365
- Platform
- Windows
Hi All
A little while back Andrew showed me that using the ADO Stream object I could preserve the recordset filter. I am using this:
This seems to order the fields alphabetically. Do you know how to avoid this, or do you know an alternative way to use the filter method on a recordset and dump the filtered results (without looping through all records)?
A little while back Andrew showed me that using the ADO Stream object I could preserve the recordset filter. I am using this:
Code:
Public Function FilterRecordSet(ByVal objRecordSet As ADODB.RecordSet, ByVal strFilterText As String) As ADODB.RecordSet
Dim objStream As ADODB.Stream
On Error Resume Next
objRecordSet.Filter = strFilterText
On Error GoTo 0
Set objStream = New ADODB.Stream
With objRecordSet
.Save objStream, adPersistXML
.Close
.Open objStream
End With
Set FilterRecordSet = objRecordSet
End Function
This seems to order the fields alphabetically. Do you know how to avoid this, or do you know an alternative way to use the filter method on a recordset and dump the filtered results (without looping through all records)?