• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1039
  • Last Modified:

Error loading DLL (CurrentProject.Connection)

Have searched the other solutions to this error without success. I have code which has always worked and now throws up an error loading dll. I've tried repairing Access 2003 and a complete reinstall but still no joy. I have no 'Missing references' under the tools menu of the VBE and all dll appear in the common files folder. The code I'm using is:

Private Sub Employee_NotInList(NewData As String, Response As Integer)

    Dim strMessage As String
    Dim rstEmployees As New ADODB.Recordset
    strMessage = "Do you want to add '" & NewData & "' to the employee list?"

    If Confirm(strMessage) Then

        rstEmployees.Open "tblEmployees", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
                                'CurrentProject.Connection is where the code stops.

        rstEmployees!EmployeeName = NewData
        Employee = rstEmployees!Employee
        Response = acDataErrAdded    
        Response = acDataErrDisplay  
    End If

End Sub

Any ideas please?
1 Solution
1. Do you have other code that sets a variable to CurrentProject.Connection and then closes the connection?

Set cn = CurrentProject.Connection
   ' ...

2. Sometimes references are messed up but don't list as Missing ... uncheck any reference, close the reference dialog, reopen references and recheck the one you unchecked. This sometimes happens when upgrading (not limited to Access upgrades)

3. Have you tried /decompile and importing into a new database?


LucasMS Dynamics DeveloperCommented:
Decompiling link here for access 97 though, same concept for 2003 i think

SoverAuthor Commented:
Hi Stevbe, thanks for the suggestions. I've tried all those now and no success. I have however loaded the database onto a laptop and the code runs fine. This is running Access 2002. Looking at the references the only difference is that the laptop uses Access 10.0 Object library and the main PC (Access 2003) refers to Access 11.0 Object Library. This reference can not be changed, I tried. Alsot he database utilities Convert Database to 2002-2003 format is blanked out as the db is already in that format. (no surprise there then).
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

SoverAuthor Commented:
Thanks for the decompile link lucas. It didn't work on this particular problem but is a useful reference.
Gustav BrockCIOCommented:
I've seen something similar.
After much trouble and testing, a reinstall (or update) of the MDAC did it. No explanation why.

You can locate and download this from the Microsoft site:


SoverAuthor Commented:
Thanks gustuv. Worked first time. As you say, no explanation why as everything checked out OK. Many thanks and many points your way. :-)
Gustav BrockCIOCommented:
Great! Thanks, I'll make a note on that. This is the second time I've met this error.

Gustav BrockCIOCommented:
2009 update.

That solution won't work on modern machines (WinXP SP3 or Vista) because these by default install a newer version - or rather Service Pack - of MDAC 2.8.

Wondering how to reinstall the MDAC I located this page:


which explains how to repair or reinstall only the MDAC from your install CDs.
Of course, if you have SP3 installed, in the guide change the refs to SP2 with SP3.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now