Solved

Getting DAO type 13 error when using currentdb

Posted on 2014-11-16
6
190 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
Comment Utility
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 119

Expert Comment

by:Rey Obrero
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
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 119

Expert Comment

by:Rey Obrero
Comment Utility
... and after uninstall you  must reboot the pc before reinstall.
0
 

Author Closing Comment

by:chtullu135
Comment Utility
Doing a repair install fixed the problem.  Thanks Scott
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now