Microsoft KB Archive/282355

= ACC2002: Mismatched Data Types in Indexes Cause Access to Quit Unexpectedly =

Article ID: 282355

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q282355



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

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



SYMPTOMS
When you use a Microsoft Visual Basic for Applications (VBA) procedure to seek matching numerical values in a table, Microsoft Access quits unexpectedly when you run the procedure.



CAUSE
The procedure attempts to match values in a field that is defined and indexed as Decimal. Because Decimal is not a VBA data type, the procedure fails and causes Access to quit.



RESOLUTION
To resolve this issue, change the Field Size property of the field in the table from Decimal to either Single or Double.



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



Steps to Reproduce the Behavior
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.  Start Access and create a new database. In the Database window, click Tables, and then click New. In the New Table dialog box, select Design View, and then click OK.  Create the following fields:   Field Name   Data Type   Field Size    Indexed --  Long1        Number      Long Integer  Yes (Duplicates OK) Dec1        Number      Decimal       Yes (Duplicates OK) </li> Save the table as Table1. When Access prompts you about whether you want to create a Primary Key, click No.</li>  Open Table1 in Datasheet view, and then create the following records: <pre class="fixed_text">  Long1     Dec1 --    1         1     2         2     3         3                    </li> On the Tools menu, point to Macro, and then click Visual Basic Editor.</li> On the Insert menu, click Module.</li> On the Tools menu, click References.</li> Click to select the Microsoft DAO 3.6 Object Library check box if it is not already selected.</li>  Type or paste the following code in the module: Sub test Dim rs As DAO.Recordset Dim testseek As Long

testseek = 1 Set rs = CurrentDb.OpenRecordset(&quot;Table1&quot;, dbOpenTable) rs.Index = &quot;Dec1&quot; rs.Seek &quot;=&quot;, 1 Debug.Print rs.NoMatch End Sub </li> On the Run menu, click Run Sub/UserForm.</li> If &quot;True&quot; appears in the Immediate window, on the Run menu, click Run Sub/UserForm again.</li></ol>

Note that Access quits unexpectedly.

<div class="references_section">