Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: "Type Mismatch" Error When Comparing Bookmarks


View products that this article applies to.

This article was previously published under Q198648
Moderate: Requires basic macro, coding, and interoperability skills.

↑ Back to the top


Symptoms

When you compare a recordset's bookmark with a Variant or String variable, you may receive the following error message:
Run-time error '13:'
Type Mismatch
This error message can also occur when you compare a recordset's bookmark to the RecordsetClone of, for example, a form's record source.

↑ Back to the top


Resolution

Use the StrComp() function to compare a Variant or String variable to a bookmark, or to compare a bookmark against a bookmark. The third argument for the StrComp() function must be set to a value of 0 (zero).

For example, the following code tests to see if a form is displaying its last record by first cloning the record source of the form, moving to the last record within the cloned recordset, and then testing to see if the last record within the cloned recordset matches the record currently displayed on the form:

NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.

Dim RS As DAO.Recordset
Set RS = Me.RecordsetClone
RS.MoveLast
If StrComp(Me.Bookmark, RS.Bookmark, 0) = 0 Then
   MsgBox "Form is displaying the last record."
End If
				

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb, and open the Customers form in Design view.
  2. Set the Customers form's OnCurrent property to the following event procedure:
    Dim RS As Recordset
    Set RS = Me.RecordsetClone
    RS.MoveLast
    If Me.Bookmark = RS.Bookmark Then
       MsgBox "Form is displaying the last record."
    End If
    					
  3. Click Form on the View menu. Note that Microsoft Access displays the following error message:
    Run-time error '13:'
    Type mismatch
  4. Click the Debug button. Note that Microsoft Access highlights the line of code where the type mismatch occurs. The line of code is:
    If Me.Bookmark = RS.Bookmark Then
    					

↑ Back to the top


References

For more information about StrComp Function, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type StrComp Function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.


For more information about Bookmark Property, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Bookmark Property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB198648, kbprb, kbprogramming, kberrmsg

↑ Back to the top

Article Info
Article ID : 198648
Revision : 2
Created on : 6/29/2004
Published on : 6/29/2004
Exists online : False
Views : 453