none
"Error in loading DLL" on call to the DAO.RecordSet.Fields property. RRS feed

  • Question

  • Hello,
     I am getting an error message when calling the DAO.RecordSet.Fields property.
     
    The error message shown on the call to the property is "Error in loading DLL(48)". Following is a VB6 code snippet which returns the error. 

        Sub Main()
          
          Dim str As String
          Dim DB As DAO.Database
          Dim DT As DAO.TableDef
          Dim RS As DAO.Recordset
          Dim lineNo As Long
          Dim s$
          Dim nFileNo As Long
          Dim Fld As DAO.Field
          Dim FldVal As Variant
             
        16: LogMsg "<Main>" 'zacra01
        17: str = Command()
          
            On Error GoTo MDBOpenError
        18: nFileNo = FreeFile
        19: Open str For Input Access Read As #nFileNo
        20: Close #nFileNo
             
            On Error GoTo DBError
        21: Set DB = OpenDatabase(str, False, True)
        22: Set RS = DB.OpenRecordset("SELECT * FROM [+Maintenance]")
        23: RS.MoveFirst
             
        24: LogMsg "<Query =" & RS.Name & ">"
        25: s$ = ""
            MsgBox "Before RS.Fields"
        26: For Each Fld In RS.Fields
            MsgBox "After RS.Fields"
        27:  s$ = s$ & Fld.Name & VBA.vbTab
        28: Next
        29: LogMsg s$ & VBA.vbNewLine & 
        ....


    The code line causing the error is marked with label "26:" (below):
        ...
        26: For Each Fld In RS.Fields
        ...

    This error occurs only on a single computer. Other computers execute this code line well. On the other computers, I can see in SysInternals' Process Explorer that right after successful execution of the line 26:, library DAO360.DLL gets loaded into the application process for the second time . That is why I suspect the error message "Error in loading DLL" says it failed to load DAO360.DLL for the second time.

    Can you think of a reason why the call to the Fields property fails to load DAO360.DLL for the second time on the particular computer while it succeeds on others?

    Thank you,
    Radovan
        
    Friday, May 26, 2017 11:51 AM

Answers

  • Fixed.
     
    It was missing KEY_CLASSES_ROOT\TypeLib\{00025E01-0000-0000-C000-000000000046} registry key. In spite of my registering Dao360.dll and Msado15.dll as stated in the second update of this thread (5th June 2017), the registry key was still absent. After adding the key as per https://support.microsoft.com/en-sg/help/2019235/microsoft-office-access-error-in-loading-dll the error message has not recurred.

    I removed or renamed the registry key on several Windows machines to verify the absence of the key is the cause of the error message. Removing or renaming the key always led to DAO.Recordset.Fields and DAO.Database.TableDefs properties returning the "Error in loading DLL" message.

    Thank you for your help Celeste and Dirk.

    Radovan
    • Proposed as answer by Chenchen LiModerator Friday, July 7, 2017 9:44 AM
    • Marked as answer by Radek7 Friday, July 7, 2017 11:28 AM
    Friday, July 7, 2017 9:23 AM

All replies

  • I'm not sure what the problem is, but the fact that it occurs only on one machine suggests that maybe DAO isn't properly installed on that machine.  Is the database in question an .mdb file, or is it an .accdb?  Is any version of Access installed on that machine, or just DAO alone?  If Access is installed, can the database be opened in Access?


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html


    Friday, May 26, 2017 12:28 PM
  • Hello,

    According to the error and your description, I suggest you visit the following links to check the registry keys of DAO360.DLL and how to register the Dao360.dll.

    Microsoft Office Access: "Error in loading dll"

    "Error in loading DLL" error message when you run a Microsoft Access wizard in Access

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 29, 2017 3:24 AM
    Moderator
  • Hello Dirk,
     thank you for your reply.
     
    These are my answers your questions:

    Is the database in question an .mdb file, or is it an .accdb? 
      [Radovan] It is and .MDB file.

    Is any version of Access installed on that machine, or just DAO alone?
      [Radovan] MS Office 2010 including Access is installed on the machine. The machine is running Windows 7 (6.1.xxxx) Japanese. DAO is hence installed alongside the operating system.

    If Access is installed, can the database be opened in Access?
      [Radovan] Yes, the .MDB file can be opened and edited in Access.

    Thank you,
    Radovan
    Monday, June 5, 2017 2:07 PM
  • Hello Celeste,
     thank you for your reply.
     
     I checked the links in your reply. The suggested remedies, however, did not help. 

      Per KB833220 (https://support.microsoft.com/en-sg/help/833220/-error-in-loading-dll-error-message-when-you-run-a-microsoft-access-wizard-in-access)
      1) I re-registered Dao360.dll and Msado15.dll at C:\Program Files\Common Files\microsoft shared\DAO and C:\Program Files\Common Files\System\ado resp.
      2) Downloaded MDAC 2.8 SP1 installer from http://msdn.microsoft.com/en-us/data/aa937729.aspx and tried to run it. The installation spewed out a few progress dialogs, but I do not think it installed anything since Windows 7, which is the troublesome machine OS, installs the latest DAO alongside. Moreover all files at C:\Program Files\Common Files\microsoft shared\DAO and C:\Program Files\Common Files\System\ado are modifiable only by "TrustedInstaller".
      
     I tried my own fix which consisted in renaming folders DAO\ and ado\ at C:\Program Files\Common Files\microsoft shared\ and C:\Program Files\Common Files\System\ resp. and running
      
        sfc /scannow
        
        to have Windows reinstall the potentially corrupted DAO files. The sfc utility restored the renamed DAO\ and ado\ folders with the original OS version.

      After each attempt - 1,2, my own - I verified whether the VB6 code snippet terminates with the "Error in loading DLL" message and it always did.

    Would you have more ideas in store as to the cause and fix for this error?

    Thank you,
    Radovan



    • Edited by Radek7 Monday, June 5, 2017 2:15 PM
    Monday, June 5, 2017 2:14 PM
  • Thanks for your answers, Radovan.  Could there be a difference in the "bit-ness" of the installed version of Access and DAO, versus the VB code?  That is, could it be that the installed version of Access is, say 64-bit while the code is targeting a 32-bit environment, or vice versa?

    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Monday, June 5, 2017 5:59 PM
  • Hello Dirk.
    The systeminfo command on the machine outputs:
     ...
     System Type:               X86-based PC
     ...

    Hence, the Windows OS running on the machine is  a 32-bit one. Access, DAO and the VB code are 32-bit ones as well.

    Thank you,
    Radovan


    Thursday, June 22, 2017 9:13 AM
  • Hello,

    According to the error message: Error in loading DLL (Error 48),

    This error has the following causes and solutions: 
    • The DLL references another DLL that isn't present. 

      Obtain the referenced DLL and make it available to the other DLL.

    • The DLL or one of the referenced DLLs isn't in a directory specified by your path. 

      Move the DLL to a referenced directory or place its current directory on the path.

    Please visit the similar thread:

    https://social.microsoft.com/Forums/en-US/1b61ba0f-7c85-4e58-afec-b626347bdbd3/cause-of-error-48-error-in-loading-dll-when-running-vb6-application?forum=Offtopic

    Do you try to write similar code in VBE of MS Access to call the dll? Would you get the same error?

    I suggest you check your project reference. I suggest you registry the dll in your project reference folder instead of Microsoft Office folder.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 23, 2017 6:08 AM
    Moderator
  • I'm running out of things to suggest, Radovan.  I assume that the purpose of the code block that opens the file for input access is just to verify that the file is there and can be opened, though I would have written "For Binary Access Read" rather than for "Input Access Read".  That's probably irrelevant, but can I also assume that you still get the DLL error if you comment out that whole block?

    Have you tried to see if you can access other aspects of the opened database object.  for example, does this give an error:

        Debug.Print DB.TableDefs.Count

    ?

    I'm guessing that when you said the database can be opened in Access, that was Access 2010 that you opened it with.  But Access 2010 would be using the Access Connectivity Engine (which is the "new, improved DAO") and VB would not be using that DLL.  So possibly there's some conflict there.  Do you know which of the .mdb formats your database is using?  Can it be opened in Access 2003?  2000?  97?

    What happens if you use late binding, declaring your object variables as Object:

        Dim DB As Object
        Dim DT As Object
        Dim RS As Object
        Dim Fld As Object

    ?


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Friday, June 23, 2017 7:44 PM
  • Fixed.
     
    It was missing KEY_CLASSES_ROOT\TypeLib\{00025E01-0000-0000-C000-000000000046} registry key. In spite of my registering Dao360.dll and Msado15.dll as stated in the second update of this thread (5th June 2017), the registry key was still absent. After adding the key as per https://support.microsoft.com/en-sg/help/2019235/microsoft-office-access-error-in-loading-dll the error message has not recurred.

    I removed or renamed the registry key on several Windows machines to verify the absence of the key is the cause of the error message. Removing or renaming the key always led to DAO.Recordset.Fields and DAO.Database.TableDefs properties returning the "Error in loading DLL" message.

    Thank you for your help Celeste and Dirk.

    Radovan
    • Proposed as answer by Chenchen LiModerator Friday, July 7, 2017 9:44 AM
    • Marked as answer by Radek7 Friday, July 7, 2017 11:28 AM
    Friday, July 7, 2017 9:23 AM
  • Hello Radovan,

    We are glad that you fix it and thanks for sharing the solution here. And I suggest you mark it as answer to close this thread.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 7, 2017 9:46 AM
    Moderator