Solved

Getting DAO type 13 error when using currentdb

Posted on 2014-11-16
6
198 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
[X]
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
  • 2
  • 2
  • 2
6 Comments
 
LVL 85
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 85

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

Independent Software Vendors: 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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

691 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