Tuesday, 12 December 2017

How To Fix Access Run Time Error 13 - Type Mismatch Error


Want to know what fixes are there to solve Run-time error ‘13’: Type mismatch error? Well for the solution you need to read the complete post.  So just stuck till the end….! Start with the practical scenario that is encountered by one of the users like you only.


Issue

This particular type mismatch expression error usually comes when you try to use the “insert record” or “update record” server behavior to set the value of the column in Microsoft with an empty string (“”).


Cause

If your project contains reference of both the Data Access Objects (DAO) library and the active data objects (ado) library, you may watch multiple Recordset entries in the list when you dimension the recordset object. This error mainly occurs when you list the ADO library with some higher priority than the DAO library in the Reference dialog box. Without even knowing which Recordset entry you select from the list.

Resolution

If you only need the DAO Recordset object, make sure that reference for the DAO object library has higher priority in the Reference dialog box.

If you use both the Recordset objects DAO and ADO, dimension the objects explicitly as follows:
   Dim adoRS As ADODB.Recordset
   Dim daoRS As DAO.Recordset
Steps to reproduce the behaviour
1. Start visual studio. This will open the New Project dialog box.
2. Tap to the Open option and this will open the Form1.
3. Right-click the form1 form and then click view code. The Project1 - Form1 (Code) window appears.
4. Paste the following code in the Project1 code page:
Dim dbs AS Database
Dim rs AS Recordset  ' When you press the spacebar after "AS," the
                           ' list box includes multiple Recordset entries.
                           ' Pick any Recordset item, or type "Recordset."
Private Sub Form_Load()
Set dbs=OpenDatabase(dbname)
Set rs=dbs.OpenRecordset(source)  ' The error occurs when this line
                                        ' of code executes.
End Sub
5. Now on the Project menu, click References.  As this will open the References - Project1 dialog box. 
6. Tap Microsoft DAO 3.x Object Library, after then Microsoft ActiveX Data Objects 2.x Library, and then at the end tap to the OK option.

Note: ADO library must have the higher priority in the References dialog box list above the DAO library.
7. From the Run menu, click to the Start option just to run the program. You will get the error that is mentioned above in the symptom section.

 Conclusion:

Now you must have got a clear idea that what makes this Access Run Time error 13 : Type mismatch error and what fixes you need to try in order to fix it soon.


1 comment:

  1. you should try this freeware tool to fix corrupt Access database. this Access Database Recovery tool allow the user to see the preview of recover data So that user can verify their data.

    ReplyDelete