Error when Adding DAO 3.5 to references

I moved a piece of code from a working Access application application into a new one.  I'm trying to compile and get and error "User defined type not defined" on the statement

Function GetFiles(strPath As String, _
                  dctDict As Dictionary, _
                  Optional blnRecursive As Boolean) As Boolean

I noticed the DAO reference wasn't present in the new module but when I try to add 'MS DAO 3.5' to the references I get an error 'Name conflicts with existing module, project or Library'.

I attached a document with a picture of the current references.  Can anyone see the conflict and tell me how to resolve it so the relocated piece of code will compile.

Here is all of the code:

Function SearchDirectory()
   Dim dctDict As Dictionary
   Dim varItem As Variant
   Dim GetTempDir As String
   GetTempDir = SearchHere
   ' Create new dictionary.
   Set dctDict = New Dictionary
   ' Call recursively, return files into Dictionary object.
   If GetFiles(GetTempDir, dctDict, True) Then
      ' Print items in dictionary.
      'For Each varItem In dctDict
         'Debug.Print varItem
   End If
DoCmd.RunMacro "Hourglass_Off"
   If Me.numFound = 0 Then
        MsgBox "No WMA Files Found"
        MsgBox Trim(Str(Me.numFound)) & " Files Found, " & _
        Trim(Str(Me.numDups)) & " Duplicate were Not Moved, " & _
        Trim(Str(Me.numMoved)) & " Files Moved"
   End If

End Function

Function GetFiles(strPath As String, _
                  dctDict As Dictionary, _
                  Optional blnRecursive As Boolean) As Boolean
Dim songName As String
Dim bandName As String
Dim albumName As String
Dim trackNumber As String
Dim songNameAndBandName As String
Dim copyName As String
Dim fileExtension As String
Dim shortSongName As String
Dim songNameLength As Long
Static prevAlbumName As String
Static albumCountNum As Long
Static albumCountStr As String
Dim filePathAndName As String
   ' This procedure returns all the files in a directory into
   ' a Dictionary object. If called recursively, it also returns
   ' all files in subfolders.
   Dim fsoSysObj      As FileSystemObject
   Dim fdrFolder      As Folder
   Dim fdrSubFolder   As Folder
   Dim filFile        As File
   ' Return new FileSystemObject.

   Set fsoSysObj = New FileSystemObject
   On Error Resume Next
   ' Get folder.
   Set fdrFolder = fsoSysObj.GetFolder(strPath)
   If Err <> 0 Then
      ' Incorrect path.
      GetFiles = False
      GoTo GetFiles_End
   End If
   On Error GoTo 0
   ' Loop through Files collection, moving any wma's to new directory.
   For Each filFile In fdrFolder.Files
        filePathAndName = filFile.Path
    '    Debug.Print "before change"
    '    Debug.Print filePathAndName
    '    filePathAndName = removeFunkyCharacters(filePathAndName)       ' remove single quote form string, not needed after all
    '    '
    '    Debug.Print "after  change"
    '    Debug.Print filePathAndName
        If InStr(filePathAndName, ".wma") Then
            ' copy it
            Me.numFound = Me.numFound + 1
            'songName = Mid(filePathAndName, InStrRev(filePathAndName, "\") + 1)
            'bandName = getBandName(filePathAndName)
            'albumName = getAlbumName(filePathAndName)
            getSongBandAndAlbumName filePathAndName, _
                                    songName, _
                                    bandName, _
                                    albumName, _
            If prevAlbumName = albumName Then
                albumCountNum = albumCountNum + 1
                albumCountStr = getAlbumStr(albumCountNum)
                prevAlbumName = albumName
            End If
            ' Increment Album Counter For Each Album
            ' don't copy it if it's already there
            'Dim fileExtension As String
            'Dim shortSongName As String
            'Dim songNameLength As Long
            songNameLength = Len(Trim(songName))
            fileExtension = Mid(songName, songNameLength - 3, songNameLength)
            shortSongName = Mid(songName, 1, songNameLength - 4)
            songNameAndBandName = shortSongName & "-" & bandName & fileExtension
            If Me.chkPrefixAlbumAndTrack Then
                shortSongName = albumCountStr & "_" & trackNumber & "_" & shortSongName
                songNameAndBandName = albumCountStr & "_" & trackNumber & "_" & songNameAndBandName
            End If
            ' Just songname or songname with band name attached
            'copyName = songName
            copyName = songNameAndBandName
            If FileExists(MoveHere & copyName) Then
                Me.numDups = Me.numDups + 1
                FileCopy filePathAndName, MoveHere & copyName
                Me.numMoved = Me.numMoved + 1
            End If
        End If
'        If Me.numMoved > 10 Then
'            DoEvents
'        End If
   Next filFile

   ' If Recursive flag is true, call recursively.
   If blnRecursive Then
      For Each fdrSubFolder In fdrFolder.SubFolders
         GetFiles fdrSubFolder.Path, dctDict, True
      Next fdrSubFolder
   End If

   ' Return True if no error occurred.
   GetFiles = True
   Exit Function

End Function

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
To be clear, your screenshot does not list:
    Microsoft DAO x.x Object Library

I always go with 3.5 if available.
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
You've got the Office Lib selected 2x.   uncheck the bottom one.  DAO is included in the Access Database Engine Object, so you won't select it separately.

 Your problem is the dictionary declaration.  Dictionary is not part of DAO, but rather the scripting lib as is the file system object.

Look for Microsoft Scripting Runtime and add it to the references.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mlcktmguyAuthor Commented:
Yes, I know it doesn't list it.  As I explained in my post I get an error when trying to add it.

"I noticed the DAO reference wasn't present in the new module but when I try to add 'MS DAO 3.5' to the references I get an error 'Name conflicts with existing module, project or Library'."
mlcktmguyAuthor Commented:
Thanks, Perfect
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.