Microsoft KB Archive/313204

= BUG: ADO Recordset Filter Is Removed After You Set Sort Property =

Article ID: 313204

Article Last Modified on 12/14/2001

-

APPLIES TO


 * Microsoft ActiveX Data Objects 1.0
 * Microsoft ActiveX Data Objects 1.5
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.01
 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q313204



SYMPTOMS
If you set the filter property of an ADO recordset to an array of bookmarks and subsequently set the sort property, the filter is removed. In addition, all records are visible again in the recordset.



RESOLUTION
To work around this problem, sort the data in the query that is used to open the recordset.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new Data Project in Visual Basic. The frmDataEnv form is created by default. Place a Button control on frmDataEnv.  Add the following code to the button's Click event: Dim oCn As New ADODB.Connection Dim oRs As New ADODB.Recordset oCn.Open &quot;provider=sqloledb;data source=(local);user id=me;initial catalog=northwind;&quot; oRs.CursorLocation = adUseClient oRs.Open &quot;SELECT * from Shippers&quot;, oCn oRs.Filter = Array(oRs.Bookmark) MsgBox oRs.RecordCount oRs.Sort = &quot;CompanyName ASC&quot; MsgBox oRs.RecordCount oRs.Close oCn.Close Set oRs = Nothing Set oCn = Nothing  Run the project, and click the button. The first message box, which displays the record count after the filter is applied, correctly displays 1. Click OK to dismiss the first message box. The next message box, which displays the original number of records, incorrectly displays 4. Notice that the filter has been removed.</ol>

Keywords: kbbug kbpending KB313204

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.