Solved

Getting DAO type 13 error when using currentdb

Posted on 2014-11-16
6
197 Views
Last Modified: 2014-11-16
Hello,
I am getting a type 13 mismatch error on line Set dbs = CurrentDb().  I've checked the syntax and I've explicitly declared them as DAO objects.  So I'm not sure what is going on.

Private Function GetPlanRecordCount(strCUID As String) As Long
    Dim rst As DAO.Recordset
    Dim lngRecordCount As Long
    Dim dbs As DAO.Database
    
    Dim strSQL As String
    
    strSQL = "SELECT * FROM Savings INNER JOIN Projects ON Savings.Proj_ID = Projects.Proj_ID"
    strSQL = strSQL & " WHERE Savings.CUID = '" & strCUID & "'"
    
    Set dbs = CurrentDb()
    Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
    If rst.AbsolutePosition > -1 Then
        rst.MoveLast
        lngRecordCount = rst.RecordCount
    Else
        lngRecordCount = 0
    End If
    GetPlanRecordCount = lngRecordCount
        
        
End Function

Open in new window

0
Comment
Question by:chtullu135
  • 2
  • 2
  • 2
6 Comments
 
LVL 84
ID: 40445924
First check your references and make sure none are marked as "MISSING". If so, you'd have to correct that.

If there is none marked as such, try unchecking one of your refs (remember what it is), and then close and reopen the reference dialog and re-check the one you unchecked earlier. This forces Access to rebuild the references, which can sometimes fix issues like this.

Otherwise, I'd be thinking along the lines of corruption. Make a backup, then do this:

1. Compact the database
2. Compile it - from the VBA Editor click Debug - Compile. Fix any errors, and keep doing this until the menu item is disabled.
3. Compact again.

You may need to Decompile the database. To do this, create a shortcut with this as the Target:

"full path to msaccess.exe" "full path to your database" /decompile

Run the shortcut, then run the 3 items above again.

You may also need to create a new, blank database and import everything into that database.

Finally, be sure that your Windows and Office installations are fully up to date.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40445965
if you have in your reference ADO libraries, make sure that the DAO library is in the top most possible position
you can do this by selecting the DAO library and clicking the Up Arrow priority button
0
 

Author Comment

by:chtullu135
ID: 40445993
Hello,
I tried as you suggested except for the last three items.  It occurred to me that there could be a problem with the installation on Access on my machine.  I installed the application on my laptop, where I have access 2007 loaded and everything worked fine.  One thing I did noticed on the problem machine, was that when I attempted to open the code window, I would get a the installer come up with the following message "Please wait fore windows configure microsoft visual studio 2010 professional enu".  I had never seen this before.  I do have visual studio 2010 professional installed and it seems to be running correctly.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40446009
I've seen that error before ... in my case, it meant I had troubles with the install of Access on my machine. I had to do a Repair install, but sometimes you must remove and reinstall Access or Office.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40446014
... and after uninstall you  must reboot the pc before reinstall.
0
 

Author Closing Comment

by:chtullu135
ID: 40446184
Doing a repair install fixed the problem.  Thanks Scott
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question