ACC2002: Mismatched Data Types in Indexes Cause Access to Quit Unexpectedly (282355)



The information in this article applies to:

  • Microsoft Access 2002

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.

MORE INFORMATION

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.
  1. Start Access and create a new database.
  2. In the Database window, click Tables, and then click New.
  3. In the New Table dialog box, select Design View, and then click OK.
  4. Create the following fields:
       Field Name   Data Type   Field Size    Indexed
       ----------------------------------------------------------
       Long1        Number      Long Integer  Yes (Duplicates OK)
       Dec1         Number      Decimal       Yes (Duplicates OK)
    					
  5. Save the table as Table1. When Access prompts you about whether you want to create a Primary Key, click No.
  6. Open Table1 in Datasheet view, and then create the following records:
       Long1     Dec1
       --------------
         1         1
         2         2
         3         3
    					
  7. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  8. On the Insert menu, click Module.
  9. On the Tools menu, click References.
  10. Click to select the Microsoft DAO 3.6 Object Library check box if it is not already selected.
  11. 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("Table1", dbOpenTable)
    rs.Index = "Dec1"
    rs.Seek "=", 1
    Debug.Print rs.NoMatch
    End Sub
    					
  12. On the Run menu, click Run Sub/UserForm.
  13. If "True" appears in the Immediate window, on the Run menu, click Run Sub/UserForm again.
Note that Access quits unexpectedly.

REFERENCES

For more information about indexes, click Microsoft Access Help on the Help menu, type indexed property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbbug kbnofix KB282355