?
Solved

Getting DAO type 13 error when using currentdb

Posted on 2014-11-16
6
Medium Priority
?
200 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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

Industry Leaders: 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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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 …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 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