Microsoft KB Archive/282383

= ACC2002: FindFirst that uses LIKE behaves differently in DAO snapshots and DAO dynasets =

Article ID: 282383

Article Last Modified on 2/1/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q282383



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).



SYMPTOMS
When you perform a search that uses the FindFirst method and LIKE without a wildcard character (&quot;*&quot;), you get different results in a DAO snapshot recordset and a DAO dynaset recordset. Using a DAO snapshot, the search acts as if the wildcard character (&quot;*&quot;) was added to the end of the search string. For example, in a table that contains the names Greg, Jacob, Nick, John, Joe, and Michael, searching for &quot;LIKE Jaco&quot; finds a match in a DAO snapshot. However, FindFirst does not find a match in a DAO dynaset.



RESOLUTION
If you want the search to act as if it appends the wildcard character (&quot;*&quot;) to the end of your search string, use a DAO snapshot.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the behavior
 Create a new Access database. Create a table named Names that contains a Text field named FirstName. Add the names Greg, Jacob, Nick, John, Joe, and Michael to the Names table.  Enter the following code in a new module in this database: Public Sub TestLIKE

Dim dbs As DAO.Database Dim rsNamesSnapshot As DAO.Recordset Dim rsNamesDynaset As DAO.Recordset Dim strSearch As String Set dbs = CurrentDb Set rsNamesSnapshot = dbs.OpenRecordset(&quot;Names&quot;, dbOpenSnapshot) Set rsNamesDynaset = dbs.OpenRecordset(&quot;Names&quot;, dbOpenDynaset) strSearch = &quot;Jaco&quot; ' Search the Snapshot recordset. rsNamesSnapshot.FindFirst &quot;FirstName LIKE '&quot; & strSearch & &quot;'&quot; If rsNamesSnapshot.NoMatch Then Debug.Print &quot;In rsNamesSnapshot, &quot; & strSearch _ & &quot; was not found&quot; Else Debug.Print &quot;In rsNamesSnapshot, looked for &quot; & _ strSearch & &quot; and found &quot; & rsNamesSnapshot(&quot;FirstName&quot;) End If   ' Search the Dynaset recordset. rsNamesDynaset.FindFirst &quot;FirstName LIKE '&quot; & strSearch & &quot;'&quot; If rsNamesDynaset.NoMatch Then Debug.Print &quot;In rsNamesDynaset, &quot; & strSearch & &quot; was not found&quot; Else Debug.Print &quot;In rsNamesDynaset, looked for &quot; & strSearch & _ &quot; and found &quot; & rsNamesDynaset(&quot;FirstName&quot;) End If   ' Print a blank line. Debug.Print End Sub  On the Tools menu, click References, and then add a reference to the Microsoft DAO 3.6 Object Library.</li> In the Immediate window, type TestLIKE, and then press ENTER. Note that the match was found with the snapshot recordset, but not the dynaset recordset.</li></ol>

Additional query words: pra

Keywords: kbbug kbnofix KB282383

-

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

© Microsoft Corporation. All rights reserved.