Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Getting DAO type 13 error when using currentdb

Posted on 2014-11-16
6
195 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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